-
Notifications
You must be signed in to change notification settings - Fork 168
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor(timestamp): remove redundant .UTC()
call and mentions
#108
Conversation
I'm happy to accept a change that removes the call to UTC in Timestamp, can you add a benchmark that demonstrates the benefit? But I'm not sure it's common knowledge that "Unix timestamp" means normalizing to UTC, so I'd prefer that bit of information to remain in the doc comment. |
bcd6985
to
461ae4e
Compare
To me, mentioning UTC the way it currently is in the docs casts a shadow of doubt on the underlying implementation, e.g. whether Performance improvements are a secondary concern, but there are some benefits there, too. Benchmark added in 461ae4e. |
I'd like also to point out that neither |
Distant observer here, I wanted to verify the assertions here, and after writing some code to verify for myself I can see the information is accurate. Personally, however, I also appreciate it when the docs are explicit about UTC. It's a tricky one that catches folk out. NB. as I was writing the above tests, I noticed, Go 1.17 introduced a timestamp in milliseconds which may also simplify some of the code in this package. May also be worth thinking about if the version can be upped at all. UnixMilli: https://pkg.go.dev/time#UnixMilli |
It's important to make clear that ULID timestamps are always UTC. It's not obvious that e.g. ulid.Now will produce UTC timestamps, because it's not obvious that Unix timestamps are always UTC. I'm fine to remove the call to UTC() in the implementation, but rather than removing the note about UTC in the docs for that one function, I think we should actually add a note about UTC to the docs of every function that produces timestamps. |
Unix timestamps are always from UTC epoch, and calculation from given `time.Time` is independent of its location.
461ae4e
to
a66f10a
Compare
I disagree with this and the conclusion to add more redundant information to docs due to reasons stated earlier. To me, the definition of Unix time is clear about its relation to UTC.
Anyway, rebased and removed the contentious doc tweak, I'll leave addressing the docs to someone else. |
Co-authored-by: Peter Bourgon <[email protected]>
df7c380
to
4147f3e
Compare
Unix timestamps are always from UTC epoch, and calculation from given
time.Time
is independent of its location.