-
Notifications
You must be signed in to change notification settings - Fork 18k
time.Time{}.Add() behaviour has changed in 1.17 #48608
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
Comments
I'm more confused by the fact that it still works for 1 second either side of that number: https://play.golang.org/p/kj7t6ZYNl79 |
OK I think I understand the issue a bit better now. I think this is pretty edge case as it will only happen on that specific second ( Here's some info from walking through with a debugger with a breakpoint here:
|
This changed due to https://golang.org/cl/300890. I think some odd handling in the overflow case is inevitable. I don't think there is anything to do here, but please comment if you have a suggestion for something we could change. |
Unfortunately I have no idea how to handle it nicely! This turned into more of a learning experience, hopefully others might find it useful/interesting! Cheers |
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
Adding 1000 (1e3) to a
time.Time
with Nanoseconds set to999999999
doesn't increment the second anymore. This worked in go1.16.8
but is now not incrementing the second in go1.17.1
https://play.golang.org/p/DxYFLO40v6R
go 1.16 output:
go 1.17 output:
What did you expect to see?
Same behaviour where the second is incremented correctly
What did you see instead?
The nanoseconds loop back around in the same way but the second is no longer incremented
The text was updated successfully, but these errors were encountered: