Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.Sign up
time: allows signs for year/tz in format string #11128
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.