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

Date parsing not fully RFC 3339 compatible #246

Closed
mmakaay opened this issue Jul 1, 2019 · 2 comments · Fixed by #292
Closed

Date parsing not fully RFC 3339 compatible #246

mmakaay opened this issue Jul 1, 2019 · 2 comments · Fixed by #292
Labels

Comments

@mmakaay
Copy link

mmakaay commented Jul 1, 2019

Using the following input:

date = 2019-10-10t11:12:13z

I get the error:
Error decoding TOML: Near line 1 (last key parsed ''): expected a top-level item to end with a newline, comment, or EOF, but got 't' instead

The expected output is something like:

{
   "date" : {
      "type" : "datetime",
      "value" : "2019-10-10T11:12:13Z"
   }
}

According to RFC 3339 and the toml ABNF, the "T" and "Z" part of a date/time value are case insensitive and can therefore be lower case characters.

@mmakaay
Copy link
Author

mmakaay commented Jul 1, 2019

Funny, the github syntax highlighter does approve of the "t", but not the "z", but they both are valid for date/time definitions.

@arp242
Copy link
Collaborator

arp242 commented Jun 8, 2021

It looks like this is a limitation of the Go time package, which looks just at Z (and T).

RFC 3339 says:

  NOTE: Per [ABNF] and ISO8601, the "T" and "Z" characters in this
  syntax may alternatively be lower case "t" or "z" respectively.

  This date/time format may be used in some environments or contexts
  that distinguish between the upper- and lower-case letters 'A'-'Z'
  and 'a'-'z' (e.g. XML).  Specifications that use this format in
  such environments MAY further limit the date/time syntax so that
  the letters 'T' and 'Z' used in the date/time syntax must always
  be upper case.  Applications that generate this format SHOULD use
  upper case letters.

So it doesn't strictly disallow limiting to just an upper-case "Z" or "T" and implementations MAY limit this.

I'm not super-pedantic about allowing a t or z, but working around the Go time package parsing is probably a bit too much; I found this open issue for it, so ideally that should really be fixed first.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants