Join GitHub today
GitHub is home to over 36 million developers working together to host and review code, manage projects, and build software together.Sign up
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.