jeremyfa / yaml.js

Standalone JavaScript YAML 1.2 Parser & Encoder. Works under node.js and all major browsers. Also brings command line YAML/JSON conversion tools.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Timestamp parsing fails when offset omits colon

joallard opened this issue · comments

While ISO8601 permits omission of colon separators anywhere,

YAML.parse("a: 2018-01-31T16:40:39-0500")
// Object { a: Date 2018-01-31T16:40:39.050Z }
// Incorrect: Offset without colon interpreted as decimal

YAML.parse("a: 2018-01-31T16:40:39.01-0500")
// Object { a: "2018-01-31T16:40:39.01-0500" }
// Failure: With decimal and non-colon offset, not parsed

YAML.parse("a: 2001-12-14t21:59:43.10-05:00")
// Object { a: Date 2001-12-15T02:59:43.100Z }
// Correct: With decimal and colon offset

YAML.parse("a: 2001-12-14t01:59:43-05:00")
// Object { a: Date 2001-12-14T06:59:43.000Z }
// Correct: Without decimal, with colon

(0.3.0)