Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.Sign up
GitHub is where the world builds software
Millions of developers and companies build, ship, and maintain their software on GitHub — the largest and most advanced development platform in the world.
time: Unix(sec, nanonsec) has bizarre undocumented behavior for large values of sec #10906
The biggest value that can be passed as the first parameter of time.Unix(seconds, nanos) is
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.
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 <email@example.com>