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 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
180 | 180 |
181 // Test creation with large date values. | 181 // Test creation with large date values. |
182 d = new Date(1969, 12, 1, 99999999999); | 182 d = new Date(1969, 12, 1, 99999999999); |
183 assertTrue(isNaN(d.getTime())); | 183 assertTrue(isNaN(d.getTime())); |
184 d = new Date(1969, 12, 1, -99999999999); | 184 d = new Date(1969, 12, 1, -99999999999); |
185 assertTrue(isNaN(d.getTime())); | 185 assertTrue(isNaN(d.getTime())); |
186 d = new Date(1969, 12, 1, Infinity); | 186 d = new Date(1969, 12, 1, Infinity); |
187 assertTrue(isNaN(d.getTime())); | 187 assertTrue(isNaN(d.getTime())); |
188 d = new Date(1969, 12, 1, -Infinity); | 188 d = new Date(1969, 12, 1, -Infinity); |
189 assertTrue(isNaN(d.getTime())); | 189 assertTrue(isNaN(d.getTime())); |
| 190 d = new Date(1969, 12, 1, 0); |
| 191 d.setTime(Math.pow(2, 64)); |
| 192 assertTrue(isNaN(d.getTime())); |
| 193 d = new Date(1969, 12, 1, 0); |
| 194 d.setTime(Math.pow(-2, 64)); |
| 195 assertTrue(isNaN(d.getTime())); |
190 | 196 |
191 | 197 |
192 // Test creation with obscure date values. | 198 // Test creation with obscure date values. |
193 assertEquals(8640000000000000, Date.UTC(1970, 0, 1 + 100000001, -24)); | 199 assertEquals(8640000000000000, Date.UTC(1970, 0, 1 + 100000001, -24)); |
194 assertEquals(-8640000000000000, Date.UTC(1970, 0, 1 - 100000001, 24)); | 200 assertEquals(-8640000000000000, Date.UTC(1970, 0, 1 - 100000001, 24)); |
195 | 201 |
196 | 202 |
197 // Parsing ES5 ISO-8601 dates. | 203 // Parsing ES5 ISO-8601 dates. |
198 // When TZ is omitted, it defaults to 'Z' meaning UTC. | 204 // When TZ is omitted, it defaults to 'Z' meaning UTC. |
199 | 205 |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
306 var hh = (i < 10) ? "0" + i : "" + i; | 312 var hh = (i < 10) ? "0" + i : "" + i; |
307 for (var j = 0; j < 60; j += 15) { | 313 for (var j = 0; j < 60; j += 15) { |
308 var mm = (j < 10) ? "0" + j : "" + j; | 314 var mm = (j < 10) ? "0" + j : "" + j; |
309 var ms = (i * 60 + j) * 60000; | 315 var ms = (i * 60 + j) * 60000; |
310 var string = "1972-03-28T23:50:03.500-" + hh + ":" + mm; | 316 var string = "1972-03-28T23:50:03.500-" + hh + ":" + mm; |
311 assertEquals(70674603500 + ms, Date.parse(string), string); | 317 assertEquals(70674603500 + ms, Date.parse(string), string); |
312 string = "1972-03-28T23:50:03.500+" + hh + ":" + mm; | 318 string = "1972-03-28T23:50:03.500+" + hh + ":" + mm; |
313 assertEquals(70674603500 - ms, Date.parse(string), string); | 319 assertEquals(70674603500 - ms, Date.parse(string), string); |
314 } | 320 } |
315 } | 321 } |
OLD | NEW |