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 month, day, hour, min, sec, and nsec values may be outside their usual ranges and will be normalized during the conversion. For example, October 32 converts to November 1.
So, your result is expected. A 0 day doesn't mean "not set", but one day less than the first day.
Although the documentation says it, it's inconsistent that a date set to "2010-1-0" been modified to "2009-12-31", when the most logical is that it been changed to "2010-1-1".
I understand that it can be confusing, but changing the behavior would break the Go 1 compatibility promise for the API. There's really nothing we can do. Sorry.
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes
What did you do?
Set a year-month layout with a day to zero.
https://play.golang.org/p/NYVZhLzzicL
What did you expect to see?
When I set a time to
time.Date(2010, time.January, 0, 0, 0, 0, 0, time.UTC)
, I expected to see2010-01-01 00:00:00 +0000 UTC
What did you see instead?
2009-12-31 00:00:00 +0000 UTC
So, to get a valid date, it changes both year and month -which had been set by me-, instead of changing the day value to
1
.The text was updated successfully, but these errors were encountered: