| 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 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // ------------------------------------------------------------------- | 5 // ------------------------------------------------------------------- |
| 6 | 6 |
| 7 (function(global, utils) { | 7 (function(global, utils) { |
| 8 | 8 |
| 9 "use strict"; | 9 "use strict"; |
| 10 | 10 |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 // Cached time value. | 127 // Cached time value. |
| 128 time: 0, | 128 time: 0, |
| 129 // String input for which the cached time is valid. | 129 // String input for which the cached time is valid. |
| 130 string: null | 130 string: null |
| 131 }; | 131 }; |
| 132 | 132 |
| 133 | 133 |
| 134 function DateConstructor(year, month, date, hours, minutes, seconds, ms) { | 134 function DateConstructor(year, month, date, hours, minutes, seconds, ms) { |
| 135 if (!%_IsConstructCall()) { | 135 if (!%_IsConstructCall()) { |
| 136 // ECMA 262 - 15.9.2 | 136 // ECMA 262 - 15.9.2 |
| 137 return %_CallFunction(new GlobalDate(), DateToString); | 137 return %_Call(DateToString, new GlobalDate()); |
| 138 } | 138 } |
| 139 | 139 |
| 140 // ECMA 262 - 15.9.3 | 140 // ECMA 262 - 15.9.3 |
| 141 var argc = %_ArgumentsLength(); | 141 var argc = %_ArgumentsLength(); |
| 142 var value; | 142 var value; |
| 143 if (argc == 0) { | 143 if (argc == 0) { |
| 144 value = %DateCurrentTime(); | 144 value = %DateCurrentTime(); |
| 145 SET_UTC_DATE_VALUE(this, value); | 145 SET_UTC_DATE_VALUE(this, value); |
| 146 } else if (argc == 1) { | 146 } else if (argc == 1) { |
| 147 if (IS_NUMBER(year)) { | 147 if (IS_NUMBER(year)) { |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 330 var t = UTC_DATE_VALUE(this); | 330 var t = UTC_DATE_VALUE(this); |
| 331 if (NUMBER_IS_NAN(t)) return kInvalidDate; | 331 if (NUMBER_IS_NAN(t)) return kInvalidDate; |
| 332 var time_zone_string = LocalTimezoneString(this); | 332 var time_zone_string = LocalTimezoneString(this); |
| 333 return TimeString(this) + time_zone_string; | 333 return TimeString(this) + time_zone_string; |
| 334 } | 334 } |
| 335 | 335 |
| 336 | 336 |
| 337 // ECMA 262 - 15.9.5.5 | 337 // ECMA 262 - 15.9.5.5 |
| 338 function DateToLocaleString() { | 338 function DateToLocaleString() { |
| 339 CHECK_DATE(this); | 339 CHECK_DATE(this); |
| 340 return %_CallFunction(this, DateToString); | 340 return %_Call(DateToString, this); |
| 341 } | 341 } |
| 342 | 342 |
| 343 | 343 |
| 344 // ECMA 262 - 15.9.5.6 | 344 // ECMA 262 - 15.9.5.6 |
| 345 function DateToLocaleDateString() { | 345 function DateToLocaleDateString() { |
| 346 CHECK_DATE(this); | 346 CHECK_DATE(this); |
| 347 var t = UTC_DATE_VALUE(this); | 347 var t = UTC_DATE_VALUE(this); |
| 348 if (NUMBER_IS_NAN(t)) return kInvalidDate; | 348 if (NUMBER_IS_NAN(t)) return kInvalidDate; |
| 349 return LongDateString(this); | 349 return LongDateString(this); |
| 350 } | 350 } |
| (...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 728 | 728 |
| 729 | 729 |
| 730 // ECMA 262 - B.2.6 | 730 // ECMA 262 - B.2.6 |
| 731 // | 731 // |
| 732 // Notice that this does not follow ECMA 262 completely. ECMA 262 | 732 // Notice that this does not follow ECMA 262 completely. ECMA 262 |
| 733 // says that toGMTString should be the same Function object as | 733 // says that toGMTString should be the same Function object as |
| 734 // toUTCString. JSC does not do this, so for compatibility we do not | 734 // toUTCString. JSC does not do this, so for compatibility we do not |
| 735 // do that either. Instead, we create a new function whose name | 735 // do that either. Instead, we create a new function whose name |
| 736 // property will return toGMTString. | 736 // property will return toGMTString. |
| 737 function DateToGMTString() { | 737 function DateToGMTString() { |
| 738 return %_CallFunction(this, DateToUTCString); | 738 return %_Call(DateToUTCString, this); |
| 739 } | 739 } |
| 740 | 740 |
| 741 | 741 |
| 742 function PadInt(n, digits) { | 742 function PadInt(n, digits) { |
| 743 if (digits == 1) return n; | 743 if (digits == 1) return n; |
| 744 return n < %_MathPow(10, digits - 1) ? '0' + PadInt(n, digits - 1) : n; | 744 return n < %_MathPow(10, digits - 1) ? '0' + PadInt(n, digits - 1) : n; |
| 745 } | 745 } |
| 746 | 746 |
| 747 | 747 |
| 748 // ECMA 262 - 20.3.4.36 | 748 // ECMA 262 - 20.3.4.36 |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 875 "toUTCString", DateToUTCString, | 875 "toUTCString", DateToUTCString, |
| 876 "getYear", DateGetYear, | 876 "getYear", DateGetYear, |
| 877 "setYear", DateSetYear, | 877 "setYear", DateSetYear, |
| 878 "toISOString", DateToISOString, | 878 "toISOString", DateToISOString, |
| 879 "toJSON", DateToJSON | 879 "toJSON", DateToJSON |
| 880 ]); | 880 ]); |
| 881 | 881 |
| 882 %InstallToContext(["create_date_fun", CreateDate]); | 882 %InstallToContext(["create_date_fun", CreateDate]); |
| 883 | 883 |
| 884 }) | 884 }) |
| OLD | NEW |