| OLD | NEW |
| 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 + FLOOR((year-1601)/400); | 74 + FLOOR((year-1601)/400); |
| 75 } | 75 } |
| 76 | 76 |
| 77 | 77 |
| 78 function TimeFromYear(year) { | 78 function TimeFromYear(year) { |
| 79 return msPerDay * DayFromYear(year); | 79 return msPerDay * DayFromYear(year); |
| 80 } | 80 } |
| 81 | 81 |
| 82 | 82 |
| 83 function InLeapYear(time) { | 83 function InLeapYear(time) { |
| 84 return DaysInYear(YearFromTime(time)) == 366 ? 1 : 0; | 84 return DaysInYear(YearFromTime(time)) - 365; // Returns 1 or 0. |
| 85 } | |
| 86 | |
| 87 | |
| 88 function DayWithinYear(time) { | |
| 89 return DAY(time) - DayFromYear(YearFromTime(time)); | |
| 90 } | 85 } |
| 91 | 86 |
| 92 | 87 |
| 93 // ECMA 262 - 15.9.1.9 | 88 // ECMA 262 - 15.9.1.9 |
| 94 function EquivalentYear(year) { | 89 function EquivalentYear(year) { |
| 95 // Returns an equivalent year in the range [2008-2035] matching | 90 // Returns an equivalent year in the range [2008-2035] matching |
| 96 // - leap year. | 91 // - leap year. |
| 97 // - week day of first day. | 92 // - week day of first day. |
| 98 var time = TimeFromYear(year); | 93 var time = TimeFromYear(year); |
| 99 var recent_year = (InLeapYear(time) == 0 ? 1967 : 1956) + | 94 var recent_year = (InLeapYear(time) == 0 ? 1967 : 1956) + |
| (...skipping 999 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1099 "toGMTString", DateToGMTString, | 1094 "toGMTString", DateToGMTString, |
| 1100 "toUTCString", DateToUTCString, | 1095 "toUTCString", DateToUTCString, |
| 1101 "getYear", DateGetYear, | 1096 "getYear", DateGetYear, |
| 1102 "setYear", DateSetYear, | 1097 "setYear", DateSetYear, |
| 1103 "toISOString", DateToISOString, | 1098 "toISOString", DateToISOString, |
| 1104 "toJSON", DateToJSON | 1099 "toJSON", DateToJSON |
| 1105 )); | 1100 )); |
| 1106 } | 1101 } |
| 1107 | 1102 |
| 1108 SetupDate(); | 1103 SetupDate(); |
| OLD | NEW |