Skip to content

Commit 0060876

Browse files
author
Fabrice Bellard
committed
fixed Date parsing: "1997-03-08 11:19:10-0700" is a valid date and "1997-03-08T11:19:10-07" should yield an error
1 parent a6db749 commit 0060876

File tree

3 files changed

+13
-5
lines changed

3 files changed

+13
-5
lines changed

TODO

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,5 +62,5 @@ Optimization ideas:
6262
Test262o: 0/11262 errors, 463 excluded
6363
Test262o commit: 7da91bceb9ce7613f87db47ddd1292a2dda58b42 (es5-tests branch)
6464

65-
Result: 48/81934 errors, 1631 excluded, 5476 skipped
65+
Result: 47/81934 errors, 1631 excluded, 5476 skipped
6666
Test262 commit: e7e136756cd67c1ffcf7c09d03aeb8ad5a6cec0c

quickjs.c

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53427,9 +53427,14 @@ static BOOL string_get_tzoffset(const uint8_t *sp, int *pp, int *tzp, BOOL stric
5342753427
hh = hh / 100;
5342853428
} else {
5342953429
mm = 0;
53430-
if (string_skip_char(sp, &p, ':') /* optional separator */
53431-
&& !string_get_digits(sp, &p, &mm, 2, 2))
53432-
return FALSE;
53430+
if (string_skip_char(sp, &p, ':')) {
53431+
/* optional separator */
53432+
if (!string_get_digits(sp, &p, &mm, 2, 2))
53433+
return FALSE;
53434+
} else {
53435+
if (strict)
53436+
return FALSE; /* [+-]HH is not accepted in strict mode */
53437+
}
5343353438
}
5343453439
if (hh > 23 || mm > 59)
5343553440
return FALSE;
@@ -53628,6 +53633,10 @@ static BOOL js_date_parse_otherstring(const uint8_t *sp,
5362853633
string_get_milliseconds(sp, &p, &fields[6]);
5362953634
}
5363053635
has_time = TRUE;
53636+
if ((sp[p] == '+' || sp[p] == '-') &&
53637+
string_get_tzoffset(sp, &p, &fields[8], FALSE)) {
53638+
*is_local = FALSE;
53639+
}
5363153640
} else {
5363253641
if (p - p_start > 2) {
5363353642
fields[0] = val;

test262_errors.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ test262/test/annexB/language/expressions/assignmenttargettype/callexpression.js:
77
test262/test/annexB/language/expressions/assignmenttargettype/cover-callexpression-and-asyncarrowhead.js:20: SyntaxError: invalid assignment left-hand side
88
test262/test/staging/sm/Date/UTC-convert-all-arguments.js:75: Test262Error: index 1: expected 42, got Error: didn't throw Expected SameValue(«Error: didn't throw», «42») to be true
99
test262/test/staging/sm/Date/constructor-convert-all-arguments.js:75: Test262Error: index undefined: expected 42, got Error: didn't throw Expected SameValue(«Error: didn't throw», «42») to be true
10-
test262/test/staging/sm/Date/non-iso.js:76: Test262Error: Expected SameValue(«NaN», «-40071559730000») to be true
1110
test262/test/staging/sm/Date/two-digit-years.js:76: Test262Error: Expected SameValue(«915177600000», «NaN») to be true
1211
test262/test/staging/sm/Function/arguments-parameter-shadowing.js:15: Test262Error: Expected SameValue(«true», «false») to be true
1312
test262/test/staging/sm/Function/constructor-binding.js:12: Test262Error: Expected SameValue(«"function"», «"undefined"») to be true

0 commit comments

Comments
 (0)