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

toml.parse() chokes on timestamps with both fractional times and Z #20

Closed
othiym23 opened this issue Mar 17, 2015 · 1 comment
Closed

Comments

@othiym23
Copy link

I'm writing a streaming TOML generator, and am using toml to validate that the TOML I'm generating is valid. I was hacking on dates tonight and came across this oddity:

> toml.parse('ts1 = 1979-05-27T07:32:00Z')
{ ts1: Sun May 27 1979 00:32:00 GMT-0700 (PDT) }
> toml.parse('ts2 = 1979-05-27T00:32:00.999999-07:00')
{ ts2: Sun May 27 1979 00:32:00 GMT-0700 (PDT) }
> toml.parse('ts3 = 1979-05-27T07:32:00.12Z')
SyntaxError: Expected "+", "-", "_" or [0-9] but "Z" found.
> toml.parse('ts4 = ' + new Date(2017, 7, 10, 8, 34, 12, 666).toISOString())
SyntaxError: Expected "+", "-", "_" or [0-9] but "Z" found.

The workaround for now is to not use Z with fractional times, but that precludes the use of date.toISOString(), which would allow me to avoid depending on moment. It's not a huge deal either way, it's just a surprising limitation.

@BinaryMuse
Copy link
Owner

Fixed in v2.2.1. Thanks for the catch.

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

No branches or pull requests

2 participants