diff --git a/toml/_parser.ts b/toml/_parser.ts index a44497ecd0ab..1b351896f2ce 100644 --- a/toml/_parser.ts +++ b/toml/_parser.ts @@ -608,7 +608,7 @@ export function dateTime(scanner: Scanner): ParseResult { const acc = []; // example: 1979-05-27T00:32:00Z - while (/[ 0-9TZ.:-]/.test(scanner.char()) && !scanner.eof()) { + while (/[ 0-9TZ.:+-]/.test(scanner.char()) && !scanner.eof()) { acc.push(scanner.char()); scanner.next(); } diff --git a/toml/parse_test.ts b/toml/parse_test.ts index 0f0904f1f7bc..b851cbe2caaf 100644 --- a/toml/parse_test.ts +++ b/toml/parse_test.ts @@ -295,6 +295,10 @@ Deno.test({ parse("1979-05-27T00:32:00-07:00"), new Date("1979-05-27T07:32:00Z"), ); + assertEquals( + parse("1979-05-27T14:32:00+07:00"), + new Date("1979-05-27T07:32:00Z"), + ); assertEquals( parse("1979-05-27T00:32:00.999999-07:00"), new Date("1979-05-27T07:32:00.999Z"), @@ -785,8 +789,9 @@ Deno.test({ datetime: { odt1: new Date("1979-05-27T07:32:00Z"), odt2: new Date("1979-05-27T00:32:00-07:00"), - odt3: new Date("1979-05-27T00:32:00.999999-07:00"), - odt4: new Date("1979-05-27 07:32:00Z"), + odt3: new Date("1979-05-27T14:32:00+07:00"), + odt4: new Date("1979-05-27T00:32:00.999999-07:00"), + odt5: new Date("1979-05-27 07:32:00Z"), ld1: new Date("1979-05-27"), lt1: "07:32:00", lt2: "00:32:00.999999", diff --git a/toml/testdata/datetime.toml b/toml/testdata/datetime.toml index 62377a4ba2e3..1bf92c2dc209 100644 --- a/toml/testdata/datetime.toml +++ b/toml/testdata/datetime.toml @@ -1,8 +1,9 @@ [datetime] odt1 = 1979-05-27T07:32:00Z # Comment odt2 = 1979-05-27T00:32:00-07:00 # Comment -odt3 = 1979-05-27T00:32:00.999999-07:00 # Comment -odt4 = 1979-05-27 07:32:00Z # Comment +odt3 = 1979-05-27T14:32:00+07:00 # Comment +odt4 = 1979-05-27T00:32:00.999999-07:00 # Comment +odt5 = 1979-05-27 07:32:00Z # Comment ld1 = 1979-05-27 # Comment lt1 = 07:32:00 # Comment lt2 = 00:32:00.999999 # Comment