Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(229)

Side by Side Diff: src/date-delay.js

Issue 543056: Fix Date.prototype.toISOString for NaN dates and add milliseconds for... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 10 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 1030 matching lines...) Expand 10 before | Expand all | Expand 10 after
1041 // Notice that this does not follow ECMA 262 completely. ECMA 262 1041 // Notice that this does not follow ECMA 262 completely. ECMA 262
1042 // says that toGMTString should be the same Function object as 1042 // says that toGMTString should be the same Function object as
1043 // toUTCString. JSC does not do this, so for compatibility we do not 1043 // toUTCString. JSC does not do this, so for compatibility we do not
1044 // do that either. Instead, we create a new function whose name 1044 // do that either. Instead, we create a new function whose name
1045 // property will return toGMTString. 1045 // property will return toGMTString.
1046 function DateToGMTString() { 1046 function DateToGMTString() {
1047 return DateToUTCString.call(this); 1047 return DateToUTCString.call(this);
1048 } 1048 }
1049 1049
1050 1050
1051 function PadInt(n) { 1051 function PadInt(n, digits) {
1052 // Format integers to have at least two digits. 1052 if (digits == 1) return n;
1053 return n < 10 ? '0' + n : n; 1053 return n < MathPow(10, digits - 1) ? '0' + PadInt(n, digits - 1) : n;
1054 } 1054 }
1055 1055
1056 1056
1057 function DateToISOString() { 1057 function DateToISOString() {
1058 return this.getUTCFullYear() + '-' + PadInt(this.getUTCMonth() + 1) + 1058 var t = DATE_VALUE(this);
1059 '-' + PadInt(this.getUTCDate()) + 'T' + PadInt(this.getUTCHours()) + 1059 if (NUMBER_IS_NAN(t)) return kInvalidDate;
1060 ':' + PadInt(this.getUTCMinutes()) + ':' + PadInt(this.getUTCSeconds()) + 1060 return this.getUTCFullYear() + '-' + PadInt(this.getUTCMonth() + 1, 2) +
1061 '-' + PadInt(this.getUTCDate(), 2) + 'T' + PadInt(this.getUTCHours(), 2) +
1062 ':' + PadInt(this.getUTCMinutes(), 2) + ':' + PadInt(this.getUTCSeconds(), 2) +
1063 '.' + PadInt(this.getUTCMilliseconds(), 3) +
1061 'Z'; 1064 'Z';
1062 } 1065 }
1063 1066
1064 1067
1065 function DateToJSON(key) { 1068 function DateToJSON(key) {
1066 return CheckJSONPrimitive(this.toISOString()); 1069 return CheckJSONPrimitive(this.toISOString());
1067 } 1070 }
1068 1071
1069 1072
1070 // ------------------------------------------------------------------- 1073 // -------------------------------------------------------------------
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
1126 "toGMTString", DateToGMTString, 1129 "toGMTString", DateToGMTString,
1127 "toUTCString", DateToUTCString, 1130 "toUTCString", DateToUTCString,
1128 "getYear", DateGetYear, 1131 "getYear", DateGetYear,
1129 "setYear", DateSetYear, 1132 "setYear", DateSetYear,
1130 "toISOString", DateToISOString, 1133 "toISOString", DateToISOString,
1131 "toJSON", DateToJSON 1134 "toJSON", DateToJSON
1132 )); 1135 ));
1133 } 1136 }
1134 1137
1135 SetupDate(); 1138 SetupDate();
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698