You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The biggest value that can be passed as the first parameter of time.Unix(seconds, nanos) is
math.MaxInt64 - 62135596800. Sample code: http://play.golang.org/p/Ck5Ny1W-ud
62135596800 is the number of seconds, accounting for leap days, that separate the start of the Go internal epoch (year 1) from the start of the Unix epoch (1970).
time.Unix() should not leak its implementation details in this way, or else the behavior should be clearly documented.
It does not seem unreasonable, given the current spec/docs, for someone to create a time.Unix(math.MaxInt64, 0) as a sentinel value, but this leads to strange and hard-to-debug behavior.
The text was updated successfully, but these errors were encountered:
time.Unix(math.MaxInt64, 0) is expecting too much from
the undocumented implementation.
The internal epoch value is intentionally not publicly
documented.
mikioh
changed the title
time.Unix(sec, nanonsec) has bizarre undocumented behavior for large values of sec
time: Unix(sec, nanonsec) has bizarre undocumented behavior for large values of sec
May 20, 2015
It's easy for someone who wants a time bigger than any
valid time to reach for time.Unix(1<<63-1, 0), so it
makes sense to explicit say such value is not valid.
Fixes#10906 (again).
Change-Id: If71e32472ae40d86c30e629b982406040a73c4c7
Reviewed-on: https://go-review.googlesource.com/10266
Reviewed-by: Russ Cox <rsc@golang.org>
The biggest value that can be passed as the first parameter of time.Unix(seconds, nanos) is
math.MaxInt64 - 62135596800. Sample code: http://play.golang.org/p/Ck5Ny1W-ud
62135596800 is the number of seconds, accounting for leap days, that separate the start of the Go internal epoch (year 1) from the start of the Unix epoch (1970).
time.Unix() should not leak its implementation details in this way, or else the behavior should be clearly documented.
It does not seem unreasonable, given the current spec/docs, for someone to create a time.Unix(math.MaxInt64, 0) as a sentinel value, but this leads to strange and hard-to-debug behavior.
The text was updated successfully, but these errors were encountered: