-
Notifications
You must be signed in to change notification settings - Fork 17.4k
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
time: allows signs for year/tz in format string #11128
Comments
I investigated this but found it difficult to decide what to do about it. Half the timezones on the planet are negative. Some timezones are off from their neighbors by 30 minutes, though none are -59 minutes, but that's not a bug, just an unused feature. So for TZ there's nothing to do. For year, it would be possible to return an error when a negative year is parsed. But what error is this saving users of the stdlib from? I find it to be a borderline case, and I'm leaning towards "works as intended". |
For some format strings time package claims to parse dates according to some RFCs. I am sure there are cases where RFCs do not permit signs, but time package does. Also for timezone -160 I propose to not create Location with offset=0 at all (just leave it as nil). This preserves Time object unchanged after serialization/deserialization. |
On tip, the above program now panics https://go.dev/play/p/57DDuAejKx5?v=gotip
Many changes probably had an impact but issue seems solved. |
Thanks. Closing. |
The following program prints
1994-01-01 00:00:00 -0059 -0059
:Most of the RFCs does not allow that.
The text was updated successfully, but these errors were encountered: