| 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 967 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 978 // Notice that this does not follow ECMA 262 completely. ECMA 262 | 978 // Notice that this does not follow ECMA 262 completely. ECMA 262 |
| 979 // says that toGMTString should be the same Function object as | 979 // says that toGMTString should be the same Function object as |
| 980 // toUTCString. JSC does not do this, so for compatibility we do not | 980 // toUTCString. JSC does not do this, so for compatibility we do not |
| 981 // do that either. Instead, we create a new function whose name | 981 // do that either. Instead, we create a new function whose name |
| 982 // property will return toGMTString. | 982 // property will return toGMTString. |
| 983 function DateToGMTString() { | 983 function DateToGMTString() { |
| 984 return DateToUTCString.call(this); | 984 return DateToUTCString.call(this); |
| 985 } | 985 } |
| 986 | 986 |
| 987 | 987 |
| 988 function PadInt(n) { |
| 989 // Format integers to have at least two digits. |
| 990 return n < 10 ? '0' + n : n; |
| 991 } |
| 992 |
| 993 |
| 994 function DateToISOString() { |
| 995 return this.getUTCFullYear() + '-' + PadInt(this.getUTCMonth() + 1) + |
| 996 '-' + PadInt(this.getUTCDate()) + 'T' + PadInt(this.getUTCHours()) + |
| 997 ':' + PadInt(this.getUTCMinutes()) + ':' + PadInt(this.getUTCSeconds()) + |
| 998 'Z'; |
| 999 } |
| 1000 |
| 1001 |
| 1002 function DateToJSON(key) { |
| 1003 return CheckJSONPrimitive(this.toISOString()); |
| 1004 } |
| 1005 |
| 1006 |
| 988 // ------------------------------------------------------------------- | 1007 // ------------------------------------------------------------------- |
| 989 | 1008 |
| 990 function SetupDate() { | 1009 function SetupDate() { |
| 991 // Setup non-enumerable properties of the Date object itself. | 1010 // Setup non-enumerable properties of the Date object itself. |
| 992 InstallFunctions($Date, DONT_ENUM, $Array( | 1011 InstallFunctions($Date, DONT_ENUM, $Array( |
| 993 "UTC", DateUTC, | 1012 "UTC", DateUTC, |
| 994 "parse", DateParse, | 1013 "parse", DateParse, |
| 995 "now", DateNow | 1014 "now", DateNow |
| 996 )); | 1015 )); |
| 997 | 1016 |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1037 "setUTCHours", DateSetUTCHours, | 1056 "setUTCHours", DateSetUTCHours, |
| 1038 "setDate", DateSetDate, | 1057 "setDate", DateSetDate, |
| 1039 "setUTCDate", DateSetUTCDate, | 1058 "setUTCDate", DateSetUTCDate, |
| 1040 "setMonth", DateSetMonth, | 1059 "setMonth", DateSetMonth, |
| 1041 "setUTCMonth", DateSetUTCMonth, | 1060 "setUTCMonth", DateSetUTCMonth, |
| 1042 "setFullYear", DateSetFullYear, | 1061 "setFullYear", DateSetFullYear, |
| 1043 "setUTCFullYear", DateSetUTCFullYear, | 1062 "setUTCFullYear", DateSetUTCFullYear, |
| 1044 "toGMTString", DateToGMTString, | 1063 "toGMTString", DateToGMTString, |
| 1045 "toUTCString", DateToUTCString, | 1064 "toUTCString", DateToUTCString, |
| 1046 "getYear", DateGetYear, | 1065 "getYear", DateGetYear, |
| 1047 "setYear", DateSetYear | 1066 "setYear", DateSetYear, |
| 1067 "toISOString", DateToISOString, |
| 1068 "toJSON", DateToJSON |
| 1048 )); | 1069 )); |
| 1049 } | 1070 } |
| 1050 | 1071 |
| 1051 SetupDate(); | 1072 SetupDate(); |
| OLD | NEW |