| 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 24 matching lines...) Expand all Loading... |
| 35 | 35 |
| 36 // Test that dates may contain commas. | 36 // Test that dates may contain commas. |
| 37 var date0 = Date.parse("Dec 25 1995 1:30"); | 37 var date0 = Date.parse("Dec 25 1995 1:30"); |
| 38 var date1 = Date.parse("Dec 25, 1995 1:30"); | 38 var date1 = Date.parse("Dec 25, 1995 1:30"); |
| 39 var date2 = Date.parse("Dec 25 1995, 1:30"); | 39 var date2 = Date.parse("Dec 25 1995, 1:30"); |
| 40 var date3 = Date.parse("Dec 25, 1995, 1:30"); | 40 var date3 = Date.parse("Dec 25, 1995, 1:30"); |
| 41 assertEquals(date0, date1); | 41 assertEquals(date0, date1); |
| 42 assertEquals(date1, date2); | 42 assertEquals(date1, date2); |
| 43 assertEquals(date2, date3); | 43 assertEquals(date2, date3); |
| 44 | 44 |
| 45 // Test limits (+/-1e8 days from epoch) |
| 46 |
| 47 var dMax = new Date(8.64e15); |
| 48 assertEquals(8.64e15, dMax.getTime()); |
| 49 |
| 50 var dOverflow = new Date(8.64e15+1); |
| 51 assertTrue(isNaN(dOverflow.getTime())); |
| 52 |
| 53 var dMin = new Date(-8.64e15); |
| 54 assertEquals(-8.64e15, dMin.getTime()); |
| 55 |
| 56 var dUnderflow = new Date(-8.64e15-1); |
| 57 assertTrue(isNaN(dUnderflow.getTime())); |
| 58 |
| 45 | 59 |
| 46 // Tests inspired by js1_5/Date/regress-346363.js | 60 // Tests inspired by js1_5/Date/regress-346363.js |
| 47 | 61 |
| 48 // Year | 62 // Year |
| 49 var a = new Date(); | 63 var a = new Date(); |
| 50 a.setFullYear(); | 64 a.setFullYear(); |
| 51 a.setFullYear(2006); | 65 a.setFullYear(2006); |
| 52 assertEquals(2006, a.getFullYear()); | 66 assertEquals(2006, a.getFullYear()); |
| 53 | 67 |
| 54 var b = new Date(); | 68 var b = new Date(); |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 | 140 |
| 127 // Test that toLocaleTimeString only returns the time portion of the | 141 // Test that toLocaleTimeString only returns the time portion of the |
| 128 // date without the timezone information. | 142 // date without the timezone information. |
| 129 function testToLocaleTimeString() { | 143 function testToLocaleTimeString() { |
| 130 var d = new Date(); | 144 var d = new Date(); |
| 131 var s = d.toLocaleTimeString(); | 145 var s = d.toLocaleTimeString(); |
| 132 assertEquals(8, s.length); | 146 assertEquals(8, s.length); |
| 133 } | 147 } |
| 134 | 148 |
| 135 testToLocaleTimeString(); | 149 testToLocaleTimeString(); |
| OLD | NEW |