Make Date.parse accept extended years format too (#3177)

ES5.1 15.9.4.2 specifies that Date.parse (string) has to accept
at least Date Time String Format: YYYY-MM-DDTHH:mm:ss.sssZ. But
the spec allows implementation-specific fallbacks. Additionally
ES5.1 15.9.1.15.1 specifies Extended years format, but isn't
explicitly required to be accepted by Date.parse. But ES6 already
clarified that Date.parse has to accept extended years format too.

JerryScript-DCO-1.0-Signed-off-by: Csaba Osztrogonác oszi@inf.u-szeged.hu
This commit is contained in:
Csaba Osztrogonác
2019-10-01 15:08:16 +02:00
committed by Dániel Bátyai
parent 3763ac8371
commit e9664b78cd
2 changed files with 45 additions and 4 deletions
+25 -1
View File
@@ -49,7 +49,14 @@ var wrongFormats = ["",
"2015-01-01T00:60",
"2015-01-01T-1:00",
"2015-01-01T00:-1",
"2e+3"];
"2e+3",
"+2015-01-01",
"-2015-01-01",
"+02015-01-01",
"-02015-01-01",
"002015-01-01",
"+0002015-01-01",
"-0002015-01-01"];
for (i in wrongFormats) {
var d = Date.parse(wrongFormats[i]);
@@ -96,3 +103,20 @@ assert (d == 1420081200000);
d = Date.parse("2015-07-03T14:35:43.123+01:30");
assert (d == 1435928743123);
assert (Date.parse("-271821-04-20T00:00:00.000Z") == -8640000000000000)
assert (Date.parse("-000001-12-31T23:59:59.999Z") == -62167219200001)
assert (Date.parse("0000-01-01T00:00:00.000Z") == -62167219200000)
assert (Date.parse("0009-12-31T23:59:59.999Z") == -61851600000001)
assert (Date.parse("0010-01-01T00:00:00.000Z") == -61851600000000)
assert (Date.parse("0099-12-31T23:59:59.999Z") == -59011459200001)
assert (Date.parse("0100-01-01T00:00:00.000Z") == -59011459200000)
assert (Date.parse("0999-12-31T23:59:59.999Z") == -30610224000001)
assert (Date.parse("1000-01-01T00:00:00.000Z") == -30610224000000)
assert (Date.parse("1969-12-31T23:59:59.999Z") == -1)
assert (Date.parse("1970-01-01T00:00:00.000Z") == 0)
assert (Date.parse("1970-01-01T00:00:00.001Z") == 1)
assert (Date.parse("9999-12-31T23:59:59.999Z") == 253402300799999)
assert (Date.parse("+010000-01-01T00:00:00.000Z") == 253402300800000)
assert (Date.parse("+275760-09-13T00:00:00.000Z") == 8640000000000000)
assert (Date.parse("+275760-09-13T00:00:00.001Z") == 8640000000000001)