-
Notifications
You must be signed in to change notification settings - Fork 18.8k
Description
The W3C profile of the ISO 8601 format, that the IETF formalized in RFC3339, specifies two timezone formats
- "Z", meaning that the time is given in UTC, without local timezone info
- with the local time offset to UTC, allowing to compute both UTC time and local time. The offset can be either positive or negative
The two timezone formats are clearly specified both in the W3C and the IETF document.
W3C:
TZD = time zone designator (Z or +hh:mm or -hh:mm)
IETF RFC3339 ABNF:
time-zone = "Z" / time-numoffset
time-numoffset = ("+" / "-") time-hour [[":"] time-minute]
/ means OR in ABNF, as is evident from the time-numoffset definition, that tells you that ISO 8601 timezone offset can be positive or negative.
The golang RFC3339 time format is non conformant, first because it tries to use "Z" in conjunction with timezone offsets (when the meaning of "Z" is that no timezone offset was provided), and second, because it only allows positive offsets, when the W3C ISO 8601 profile and RFC3339 are both very clear offsets can be negative.
As a result, go is unable to parse RFC3339 compliant date times such as the ones outputed by date --iso-8601=seconds
$ TZ="America/Los_Angeles" date --iso-8601=seconds
2019-03-28T08:14:26-0700
$ TZ="Europe/Paris" date --iso-8601=seconds
2019-03-28T16:15:04+0100parsing time "2019-03-28T08:14:26-0700" as "2006-01-02T15:04:05Z07:00": cannot parse "-0700" as "Z07:00"
Please fix the RFC3339 time format in Go or, if the mistake is too old to be easily removed, add a new RFC3339std format that is conformant to the RFC 3339 and ISO 8601, as used by other software in IJSON, XML, etc.