Skip to content
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.ISO8601 versus ISO 8601, W3C, RFC 3339, and RFC 822 #734

Closed
gopherbot opened this issue Apr 21, 2010 · 4 comments
Closed

time.ISO8601 versus ISO 8601, W3C, RFC 3339, and RFC 822 #734

gopherbot opened this issue Apr 21, 2010 · 4 comments

Comments

@gopherbot
Copy link
Contributor

by micah.stetson:

Time.Parse() doesn't understand the full ISO 8601 grammar.  That's sensible, but not
clearly 
documented.  Instead, time.ISO8601 chooses one of the many formats allowed by ISO 8601.  
Almost.  If the errata[1] for RFC 3339[2] are correct, then time.ISO8601 may not be
allowed by ISO 
8601 because it mixes a "basic format" (no colon) time zone offset with
"extended format" 
(hyphens and colons) time and date specifications.

Since stdISO8601TZ doesn't allow a colon, there's currently no way to parse dates
formatted 
according to RFC 3339 or the W3C Note[3] on the subject.

[1] http://www.rfc-editor.org/errata_search.php?rfc=3339
[2] http://tools.ietf.org/html/rfc3339
[3] http://www.w3.org/TR/NOTE-datetime

I think the main difficulty in fixing this is just determining which format strings
should be used 
for the different time zone formats and which format time.ISO8601 should use.

I suggest the following:

    stdNumTZ = "-0700" // always numeric
    stdNumColonTZ = "-07:00" // always numeric
    stdISO8601TZB = "ZB" // ISO8601 "basic" i.e. Z or -0700, RFC822
    stdISO8601TZX = "ZX" // ISO8601 "extended" i.e. Z or -07:00, RFC3339

    ISO8601 = "20060102T150405ZB" // as used by Google Calendar
    RFC3339 = "2006-01-02T15:04:05ZX"
    OldISO8601 = "2006-01-02T15:04:05ZB" // what Go uses today

Existing uses of time.ISO8601 could be changed to time.OldISO8601 using gofmt.

If this looks good, I'm willing to do the code changes.
@robpike
Copy link
Contributor

robpike commented Apr 21, 2010

Comment 1:

Owner changed to r...@golang.org.

Status changed to Accepted.

@rsc
Copy link
Contributor

rsc commented Apr 21, 2010

Comment 2:

What a mess.
It would be nice to have a solution that didn't involve making up new strings
but I don't see a good one.  I'll never remember which one is ZB and which is ZX.
Maybe the formats should be "Z0700" and "Z07:00"?
I don't think there's a need for OldISO8601.  The code I've written using
ISO8601 was really trying to be RFC3339 and only ever dealt with UTC times.
ISO8601 = "..."  // ISO 8601 basic format
RFC3339 = "..."  // RFC 3339

@gopherbot
Copy link
Contributor Author

Comment 3 by micah.stetson:

Z0700 and Z07:00 are a definite improvement.  Your comment about OldISO8601 makes me
wonder if ISO8601 
should be dropped as well.  It suggests that time.Parse(time.ISO8601, value) will
understand any ISO 8601 date, 
which just isn't true.  Also, removing it means that code that depended on it will fail
to compile, preventing any 
sort of accidental breakage from the format change.
I've made these changes to my local copy.  I'll submit a CL for review tomorrow, if
you'd like.

@rsc
Copy link
Contributor

rsc commented Apr 27, 2010

Comment 4:

This issue was closed by revision 6c124cb.

Status changed to Fixed.

@golang golang locked and limited conversation to collaborators Jun 24, 2016
@rsc rsc removed their assignment Jun 22, 2022
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants