Index: test/mjsunit/date-parse.js |
diff --git a/test/mjsunit/date-parse.js b/test/mjsunit/date-parse.js |
index e623827df7b8235b9c87157a944e23624ebb629d..ff9c41d14948170d47b6b07b0bbd2b3d305522a7 100644 |
--- a/test/mjsunit/date-parse.js |
+++ b/test/mjsunit/date-parse.js |
@@ -232,6 +232,20 @@ var testCasesMisc = [ |
['Saturday, 01-Jan-00 08:00 PM UT', 946756800000], |
['01 Jan 00 08:00 PM +0000', 946756800000]]; |
+// TODO(littledan): This is an hack that could break in historically |
+// changing timezones that happened on this day, but allows us to |
+// check the date value for local times. |
+var localOffset = new Date('2000-01-01').getTimezoneOffset()*1000*60; |
+ |
+// Sanity check which is even more of a hack: in the timezones where |
+// these tests are likely to be run, the offset is nonzero because |
+// dates which don't include Z are in the local timezone. |
+if (this.Intl && |
+ ["America/Los_Angeles", "Europe/Berlin", "Europe/Madrid"].indexOf( |
+ Intl.DateTimeFormat().resolvedOptions().timeZone) != -1) { |
+ assertTrue(localOffset != 0); |
+} |
+ |
// Test different version of the ES5 date time string format. |
var testCasesES5Misc = [ |
['2000-01-01T08:00:00.000Z', 946713600000], |
@@ -245,9 +259,18 @@ var testCasesES5Misc = [ |
['2000-01T08:00:00.099Z', 946713600099], |
['2000-01T08:00:00.999Z', 946713600999], |
['2000-01T00:00:00.001-08:00', 946713600001], |
- ['2000-01-01T24:00', 946771200000], |
- ['2000-01-01T24:00:00', 946771200000], |
- ['2000-01-01T24:00:00.000', 946771200000], |
+ // If the timezone is absent and time is present, use local time |
ulan
2017/02/15 21:35:04
The array is named "testCasesES5Misc" but this is
|
+ ['2000-01-02T00:00', 946771200000 + localOffset], |
+ ['2000-01-02T00:00:00', 946771200000 + localOffset], |
+ ['2000-01-02T00:00:00.000', 946771200000 + localOffset], |
+ // If timezone is absent and time is absent, use UTC |
+ ['2000-01-02', 946771200000], |
+ ['2000-01-02', 946771200000], |
+ ['2000-01-02', 946771200000], |
+ // 24-hour wraparound case |
+ ['2000-01-01T24:00Z', 946771200000], |
+ ['2000-01-01T24:00:00Z', 946771200000], |
+ ['2000-01-01T24:00:00.000Z', 946771200000], |
['2000-01-01T24:00:00.000Z', 946771200000]]; |
var testCasesES5MiscNegative = [ |