Skip to content

Commit

Permalink
fix(toml):parsing positive time zone offset
Browse files Browse the repository at this point in the history
  • Loading branch information
IgorM867 committed Nov 14, 2024
1 parent 7490085 commit f767e9c
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
2 changes: 1 addition & 1 deletion toml/_parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -608,7 +608,7 @@ export function dateTime(scanner: Scanner): ParseResult<Date> {

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();
}
Expand Down
9 changes: 7 additions & 2 deletions toml/parse_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand Down Expand Up @@ -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",
Expand Down
5 changes: 3 additions & 2 deletions toml/testdata/datetime.toml
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit f767e9c

Please sign in to comment.