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.
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.
Owner Name | BurntSushi |
Repo Name | toml |
Full Name | BurntSushi/toml |
Language | Go |
Created Date | 2013-02-26 |
Updated Date | 2023-03-20 |
Star Count | 4154 |
Watcher Count | 84 |
Fork Count | 518 |
Issue Count | 15 |