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 // This file relies on the fact that the following declarations have been made | 5 // This file relies on the fact that the following declarations have been made |
6 // in v8natives.js: | 6 // in v8natives.js: |
7 // var $isFinite = GlobalIsFinite; | 7 // var $isFinite = GlobalIsFinite; |
8 | 8 |
9 var $createDate; | 9 var $createDate; |
10 | 10 |
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
243 } | 243 } |
244 | 244 |
245 | 245 |
246 function DatePrintString(date) { | 246 function DatePrintString(date) { |
247 return DateString(date) + ' ' + TimeString(date); | 247 return DateString(date) + ' ' + TimeString(date); |
248 } | 248 } |
249 | 249 |
250 // ------------------------------------------------------------------- | 250 // ------------------------------------------------------------------- |
251 | 251 |
252 // Reused output buffer. Used when parsing date strings. | 252 // Reused output buffer. Used when parsing date strings. |
253 var parse_buffer = $Array(8); | 253 var parse_buffer = new InternalArray(8); |
254 | 254 |
255 // ECMA 262 - 15.9.4.2 | 255 // ECMA 262 - 15.9.4.2 |
256 function DateParse(string) { | 256 function DateParse(string) { |
257 var arr = %DateParseString(ToString(string), parse_buffer); | 257 var arr = %DateParseString(ToString(string), parse_buffer); |
258 if (IS_NULL(arr)) return NAN; | 258 if (IS_NULL(arr)) return NAN; |
259 | 259 |
260 var day = MakeDay(arr[0], arr[1], arr[2]); | 260 var day = MakeDay(arr[0], arr[1], arr[2]); |
261 var time = MakeTime(arr[3], arr[4], arr[5], arr[6]); | 261 var time = MakeTime(arr[3], arr[4], arr[5], arr[6]); |
262 var date = MakeDate(day, time); | 262 var date = MakeDate(day, time); |
263 | 263 |
(...skipping 494 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
758 date.setTime(time); | 758 date.setTime(time); |
759 return date; | 759 return date; |
760 } | 760 } |
761 | 761 |
762 // ------------------------------------------------------------------- | 762 // ------------------------------------------------------------------- |
763 | 763 |
764 %SetCode(GlobalDate, DateConstructor); | 764 %SetCode(GlobalDate, DateConstructor); |
765 %FunctionSetPrototype(GlobalDate, new GlobalDate(NAN)); | 765 %FunctionSetPrototype(GlobalDate, new GlobalDate(NAN)); |
766 | 766 |
767 // Set up non-enumerable properties of the Date object itself. | 767 // Set up non-enumerable properties of the Date object itself. |
768 InstallFunctions(GlobalDate, DONT_ENUM, $Array( | 768 InstallFunctions(GlobalDate, DONT_ENUM, [ |
769 "UTC", DateUTC, | 769 "UTC", DateUTC, |
770 "parse", DateParse, | 770 "parse", DateParse, |
771 "now", DateNow | 771 "now", DateNow |
772 )); | 772 ]); |
773 | 773 |
774 // Set up non-enumerable constructor property of the Date prototype object. | 774 // Set up non-enumerable constructor property of the Date prototype object. |
775 %AddNamedProperty(GlobalDate.prototype, "constructor", GlobalDate, DONT_ENUM); | 775 %AddNamedProperty(GlobalDate.prototype, "constructor", GlobalDate, DONT_ENUM); |
776 | 776 |
777 // Set up non-enumerable functions of the Date prototype object and | 777 // Set up non-enumerable functions of the Date prototype object and |
778 // set their names. | 778 // set their names. |
779 InstallFunctions(GlobalDate.prototype, DONT_ENUM, $Array( | 779 InstallFunctions(GlobalDate.prototype, DONT_ENUM, [ |
780 "toString", DateToString, | 780 "toString", DateToString, |
781 "toDateString", DateToDateString, | 781 "toDateString", DateToDateString, |
782 "toTimeString", DateToTimeString, | 782 "toTimeString", DateToTimeString, |
783 "toLocaleString", DateToLocaleString, | 783 "toLocaleString", DateToLocaleString, |
784 "toLocaleDateString", DateToLocaleDateString, | 784 "toLocaleDateString", DateToLocaleDateString, |
785 "toLocaleTimeString", DateToLocaleTimeString, | 785 "toLocaleTimeString", DateToLocaleTimeString, |
786 "valueOf", DateValueOf, | 786 "valueOf", DateValueOf, |
787 "getTime", DateGetTime, | 787 "getTime", DateGetTime, |
788 "getFullYear", DateGetFullYear, | 788 "getFullYear", DateGetFullYear, |
789 "getUTCFullYear", DateGetUTCFullYear, | 789 "getUTCFullYear", DateGetUTCFullYear, |
(...skipping 26 matching lines...) Expand all Loading... |
816 "setMonth", DateSetMonth, | 816 "setMonth", DateSetMonth, |
817 "setUTCMonth", DateSetUTCMonth, | 817 "setUTCMonth", DateSetUTCMonth, |
818 "setFullYear", DateSetFullYear, | 818 "setFullYear", DateSetFullYear, |
819 "setUTCFullYear", DateSetUTCFullYear, | 819 "setUTCFullYear", DateSetUTCFullYear, |
820 "toGMTString", DateToGMTString, | 820 "toGMTString", DateToGMTString, |
821 "toUTCString", DateToUTCString, | 821 "toUTCString", DateToUTCString, |
822 "getYear", DateGetYear, | 822 "getYear", DateGetYear, |
823 "setYear", DateSetYear, | 823 "setYear", DateSetYear, |
824 "toISOString", DateToISOString, | 824 "toISOString", DateToISOString, |
825 "toJSON", DateToJSON | 825 "toJSON", DateToJSON |
826 )); | 826 ]); |
827 | 827 |
828 // Expose to the global scope. | 828 // Expose to the global scope. |
829 $createDate = CreateDate; | 829 $createDate = CreateDate; |
830 | 830 |
831 })(); | 831 })(); |
OLD | NEW |