| 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 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 344 // MakeDay(2007, 14, -50) --> MakeDay(2007, 8, 11) | 344 // MakeDay(2007, 14, -50) --> MakeDay(2007, 8, 11) |
| 345 function MakeDay(year, month, date) { | 345 function MakeDay(year, month, date) { |
| 346 if (!$isFinite(year) || !$isFinite(month) || !$isFinite(date)) return $NaN; | 346 if (!$isFinite(year) || !$isFinite(month) || !$isFinite(date)) return $NaN; |
| 347 | 347 |
| 348 // Convert to integer and map -0 to 0. | 348 // Convert to integer and map -0 to 0. |
| 349 year = TO_INTEGER_MAP_MINUS_ZERO(year); | 349 year = TO_INTEGER_MAP_MINUS_ZERO(year); |
| 350 month = TO_INTEGER_MAP_MINUS_ZERO(month); | 350 month = TO_INTEGER_MAP_MINUS_ZERO(month); |
| 351 date = TO_INTEGER_MAP_MINUS_ZERO(date); | 351 date = TO_INTEGER_MAP_MINUS_ZERO(date); |
| 352 | 352 |
| 353 if (year < kMinYear || year > kMaxYear || | 353 if (year < kMinYear || year > kMaxYear || |
| 354 month < kMinMonth || month > kMaxMonth || | 354 month < kMinMonth || month > kMaxMonth) { |
| 355 date < kMinDate || date > kMaxDate) { | |
| 356 return $NaN; | 355 return $NaN; |
| 357 } | 356 } |
| 358 | 357 |
| 359 // Now we rely on year, month and date being SMIs. | 358 // Now we rely on year and month being SMIs. |
| 360 return %DateMakeDay(year, month, date); | 359 return %DateMakeDay(year, month) + date - 1; |
| 361 } | 360 } |
| 362 | 361 |
| 363 | 362 |
| 364 // ECMA 262 - 15.9.1.13 | 363 // ECMA 262 - 15.9.1.13 |
| 365 function MakeDate(day, time) { | 364 function MakeDate(day, time) { |
| 366 var time = day * msPerDay + time; | 365 var time = day * msPerDay + time; |
| 367 // Some of our runtime funtions for computing UTC(time) rely on | 366 // Some of our runtime funtions for computing UTC(time) rely on |
| 368 // times not being significantly larger than MAX_TIME_MS. If there | 367 // times not being significantly larger than MAX_TIME_MS. If there |
| 369 // is no way that the time can be within range even after UTC | 368 // is no way that the time can be within range even after UTC |
| 370 // conversion we return NaN immediately instead of relying on | 369 // conversion we return NaN immediately instead of relying on |
| (...skipping 600 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 971 return %_CallFunction(this, DateToUTCString); | 970 return %_CallFunction(this, DateToUTCString); |
| 972 } | 971 } |
| 973 | 972 |
| 974 | 973 |
| 975 function PadInt(n, digits) { | 974 function PadInt(n, digits) { |
| 976 if (digits == 1) return n; | 975 if (digits == 1) return n; |
| 977 return n < MathPow(10, digits - 1) ? '0' + PadInt(n, digits - 1) : n; | 976 return n < MathPow(10, digits - 1) ? '0' + PadInt(n, digits - 1) : n; |
| 978 } | 977 } |
| 979 | 978 |
| 980 | 979 |
| 980 // ECMA 262 - 15.9.5.43 |
| 981 function DateToISOString() { | 981 function DateToISOString() { |
| 982 var t = DATE_VALUE(this); | 982 var t = DATE_VALUE(this); |
| 983 if (NUMBER_IS_NAN(t)) return kInvalidDate; | 983 if (NUMBER_IS_NAN(t)) throw MakeRangeError("invalid_time_value", []); |
| 984 var year = this.getUTCFullYear(); | 984 var year = this.getUTCFullYear(); |
| 985 var year_string; | 985 var year_string; |
| 986 if (year >= 0 && year <= 9999) { | 986 if (year >= 0 && year <= 9999) { |
| 987 year_string = PadInt(year, 4); | 987 year_string = PadInt(year, 4); |
| 988 } else { | 988 } else { |
| 989 if (year < 0) { | 989 if (year < 0) { |
| 990 year_string = "-" + PadInt(-year, 6); | 990 year_string = "-" + PadInt(-year, 6); |
| 991 } else { | 991 } else { |
| 992 year_string = "+" + PadInt(year, 6); | 992 year_string = "+" + PadInt(year, 6); |
| 993 } | 993 } |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1106 "toGMTString", DateToGMTString, | 1106 "toGMTString", DateToGMTString, |
| 1107 "toUTCString", DateToUTCString, | 1107 "toUTCString", DateToUTCString, |
| 1108 "getYear", DateGetYear, | 1108 "getYear", DateGetYear, |
| 1109 "setYear", DateSetYear, | 1109 "setYear", DateSetYear, |
| 1110 "toISOString", DateToISOString, | 1110 "toISOString", DateToISOString, |
| 1111 "toJSON", DateToJSON | 1111 "toJSON", DateToJSON |
| 1112 )); | 1112 )); |
| 1113 } | 1113 } |
| 1114 | 1114 |
| 1115 SetUpDate(); | 1115 SetUpDate(); |
| OLD | NEW |