OLD | NEW |
---|---|
1 // Copyright 2008 the V8 project authors. All rights reserved. | 1 // Copyright 2008 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
225 ['Sat, 01 Jan 99 08:00:00 UT', 915177600000], // year 1999 | 225 ['Sat, 01 Jan 99 08:00:00 UT', 915177600000], // year 1999 |
226 ['Sat, 01 Jan 100 08:00:00 UT', -59011430400000], // year 100 | 226 ['Sat, 01 Jan 100 08:00:00 UT', -59011430400000], // year 100 |
227 // Test PM after time. | 227 // Test PM after time. |
228 ['Sat, 01-Jan-2000 08:00 PM UT', 946756800000], | 228 ['Sat, 01-Jan-2000 08:00 PM UT', 946756800000], |
229 ['Sat, 01 Jan 2000 08:00 PM UT', 946756800000], | 229 ['Sat, 01 Jan 2000 08:00 PM UT', 946756800000], |
230 ['Jan 01 2000 08:00 PM UT', 946756800000], | 230 ['Jan 01 2000 08:00 PM UT', 946756800000], |
231 ['Jan 01 08:00 PM UT 2000', 946756800000], | 231 ['Jan 01 08:00 PM UT 2000', 946756800000], |
232 ['Saturday, 01-Jan-00 08:00 PM UT', 946756800000], | 232 ['Saturday, 01-Jan-00 08:00 PM UT', 946756800000], |
233 ['01 Jan 00 08:00 PM +0000', 946756800000]]; | 233 ['01 Jan 00 08:00 PM +0000', 946756800000]]; |
234 | 234 |
235 // TODO(littledan): This is an hack that could break in historically | |
236 // changing timezones that happened on this day, but allows us to | |
237 // check the date value for local times. | |
238 var localOffset = new Date('2000-01-01').getTimezoneOffset()*1000*60; | |
239 | |
240 // Sanity check which is even more of a hack: in the timezones where | |
241 // these tests are likely to be run, the offset is nonzero because | |
242 // dates which don't include Z are in the local timezone. | |
243 if (this.Intl && | |
244 ["America/Los_Angeles", "Europe/Berlin", "Europe/Madrid"].indexOf( | |
245 Intl.DateTimeFormat().resolvedOptions().timeZone) != -1) { | |
246 assertTrue(localOffset != 0); | |
247 } | |
248 | |
235 // Test different version of the ES5 date time string format. | 249 // Test different version of the ES5 date time string format. |
236 var testCasesES5Misc = [ | 250 var testCasesES5Misc = [ |
237 ['2000-01-01T08:00:00.000Z', 946713600000], | 251 ['2000-01-01T08:00:00.000Z', 946713600000], |
238 ['2000-01-01T08:00:00Z', 946713600000], | 252 ['2000-01-01T08:00:00Z', 946713600000], |
239 ['2000-01-01T08:00Z', 946713600000], | 253 ['2000-01-01T08:00Z', 946713600000], |
240 ['2000-01T08:00:00.000Z', 946713600000], | 254 ['2000-01T08:00:00.000Z', 946713600000], |
241 ['2000T08:00:00.000Z', 946713600000], | 255 ['2000T08:00:00.000Z', 946713600000], |
242 ['2000T08:00Z', 946713600000], | 256 ['2000T08:00Z', 946713600000], |
243 ['2000-01T00:00:00.000-08:00', 946713600000], | 257 ['2000-01T00:00:00.000-08:00', 946713600000], |
244 ['2000-01T08:00:00.001Z', 946713600001], | 258 ['2000-01T08:00:00.001Z', 946713600001], |
245 ['2000-01T08:00:00.099Z', 946713600099], | 259 ['2000-01T08:00:00.099Z', 946713600099], |
246 ['2000-01T08:00:00.999Z', 946713600999], | 260 ['2000-01T08:00:00.999Z', 946713600999], |
247 ['2000-01T00:00:00.001-08:00', 946713600001], | 261 ['2000-01T00:00:00.001-08:00', 946713600001], |
248 ['2000-01-01T24:00', 946771200000], | 262 // 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
| |
249 ['2000-01-01T24:00:00', 946771200000], | 263 ['2000-01-02T00:00', 946771200000 + localOffset], |
250 ['2000-01-01T24:00:00.000', 946771200000], | 264 ['2000-01-02T00:00:00', 946771200000 + localOffset], |
265 ['2000-01-02T00:00:00.000', 946771200000 + localOffset], | |
266 // If timezone is absent and time is absent, use UTC | |
267 ['2000-01-02', 946771200000], | |
268 ['2000-01-02', 946771200000], | |
269 ['2000-01-02', 946771200000], | |
270 // 24-hour wraparound case | |
271 ['2000-01-01T24:00Z', 946771200000], | |
272 ['2000-01-01T24:00:00Z', 946771200000], | |
273 ['2000-01-01T24:00:00.000Z', 946771200000], | |
251 ['2000-01-01T24:00:00.000Z', 946771200000]]; | 274 ['2000-01-01T24:00:00.000Z', 946771200000]]; |
252 | 275 |
253 var testCasesES5MiscNegative = [ | 276 var testCasesES5MiscNegative = [ |
254 '2000-01-01TZ', | 277 '2000-01-01TZ', |
255 '2000-01-01T60Z', | 278 '2000-01-01T60Z', |
256 '2000-01-01T60:60Z', | 279 '2000-01-01T60:60Z', |
257 '2000-01-0108:00Z', | 280 '2000-01-0108:00Z', |
258 '2000-01-01T08Z', | 281 '2000-01-01T08Z', |
259 '2000-01-01T24:01', | 282 '2000-01-01T24:01', |
260 '2000-01-01T24:00:01', | 283 '2000-01-01T24:00:01', |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
296 'May 25 2008 1:30 (PM)) UTC', // Bad unmatched ')' after number. | 319 'May 25 2008 1:30 (PM)) UTC', // Bad unmatched ')' after number. |
297 'May 25 2008 1:30( )AM (PM)', // | 320 'May 25 2008 1:30( )AM (PM)', // |
298 'a1', // Issue 126448, 53209. | 321 'a1', // Issue 126448, 53209. |
299 'nasfdjklsfjoaifg1', | 322 'nasfdjklsfjoaifg1', |
300 'x_2', | 323 'x_2', |
301 'May 25 2008 AAA (GMT)']; // Unknown word after number. | 324 'May 25 2008 AAA (GMT)']; // Unknown word after number. |
302 | 325 |
303 testCasesNegative.forEach(function (s) { | 326 testCasesNegative.forEach(function (s) { |
304 assertTrue(isNaN(Date.parse(s)), s + " is not NaN."); | 327 assertTrue(isNaN(Date.parse(s)), s + " is not NaN."); |
305 }); | 328 }); |
OLD | NEW |