Skip to content

Commit 90e4aef

Browse files
authored
fix(toml): parsing positive time zone offset (denoland#6188)
1 parent 7490085 commit 90e4aef

File tree

3 files changed

+11
-5
lines changed

3 files changed

+11
-5
lines changed

toml/_parser.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -608,7 +608,7 @@ export function dateTime(scanner: Scanner): ParseResult<Date> {
608608

609609
const acc = [];
610610
// example: 1979-05-27T00:32:00Z
611-
while (/[ 0-9TZ.:-]/.test(scanner.char()) && !scanner.eof()) {
611+
while (/[ 0-9TZ.:+-]/.test(scanner.char()) && !scanner.eof()) {
612612
acc.push(scanner.char());
613613
scanner.next();
614614
}

toml/parse_test.ts

+7-2
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,10 @@ Deno.test({
295295
parse("1979-05-27T00:32:00-07:00"),
296296
new Date("1979-05-27T07:32:00Z"),
297297
);
298+
assertEquals(
299+
parse("1979-05-27T14:32:00+07:00"),
300+
new Date("1979-05-27T07:32:00Z"),
301+
);
298302
assertEquals(
299303
parse("1979-05-27T00:32:00.999999-07:00"),
300304
new Date("1979-05-27T07:32:00.999Z"),
@@ -785,8 +789,9 @@ Deno.test({
785789
datetime: {
786790
odt1: new Date("1979-05-27T07:32:00Z"),
787791
odt2: new Date("1979-05-27T00:32:00-07:00"),
788-
odt3: new Date("1979-05-27T00:32:00.999999-07:00"),
789-
odt4: new Date("1979-05-27 07:32:00Z"),
792+
odt3: new Date("1979-05-27T14:32:00+07:00"),
793+
odt4: new Date("1979-05-27T00:32:00.999999-07:00"),
794+
odt5: new Date("1979-05-27 07:32:00Z"),
790795
ld1: new Date("1979-05-27"),
791796
lt1: "07:32:00",
792797
lt2: "00:32:00.999999",

toml/testdata/datetime.toml

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
[datetime]
22
odt1 = 1979-05-27T07:32:00Z # Comment
33
odt2 = 1979-05-27T00:32:00-07:00 # Comment
4-
odt3 = 1979-05-27T00:32:00.999999-07:00 # Comment
5-
odt4 = 1979-05-27 07:32:00Z # Comment
4+
odt3 = 1979-05-27T14:32:00+07:00 # Comment
5+
odt4 = 1979-05-27T00:32:00.999999-07:00 # Comment
6+
odt5 = 1979-05-27 07:32:00Z # Comment
67
ld1 = 1979-05-27 # Comment
78
lt1 = 07:32:00 # Comment
89
lt2 = 00:32:00.999999 # Comment

0 commit comments

Comments
 (0)