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

fix(toml): parsing positive time zone offset #6188

Merged
merged 1 commit into from
Nov 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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