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

Side by Side Diff: src/date.js

Issue 5676005: Fix regression in JSON serialization of RegExps. (Closed)
Patch Set: Added test. Created 10 years 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
« no previous file with comments | « no previous file | src/json.js » ('j') | 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 966 matching lines...) Expand 10 before | Expand all | Expand 10 after
977 977
978 function PadInt(n, digits) { 978 function PadInt(n, digits) {
979 if (digits == 1) return n; 979 if (digits == 1) return n;
980 return n < MathPow(10, digits - 1) ? '0' + PadInt(n, digits - 1) : n; 980 return n < MathPow(10, digits - 1) ? '0' + PadInt(n, digits - 1) : n;
981 } 981 }
982 982
983 983
984 function DateToISOString() { 984 function DateToISOString() {
985 var t = DATE_VALUE(this); 985 var t = DATE_VALUE(this);
986 if (NUMBER_IS_NAN(t)) return kInvalidDate; 986 if (NUMBER_IS_NAN(t)) return kInvalidDate;
987 return this.getUTCFullYear() + '-' + PadInt(this.getUTCMonth() + 1, 2) + 987 return this.getUTCFullYear() +
988 '-' + PadInt(this.getUTCDate(), 2) + 'T' + PadInt(this.getUTCHours(), 2) + 988 '-' + PadInt(this.getUTCMonth() + 1, 2) +
989 ':' + PadInt(this.getUTCMinutes(), 2) + ':' + PadInt(this.getUTCSeconds(), 2) + 989 '-' + PadInt(this.getUTCDate(), 2) +
990 'T' + PadInt(this.getUTCHours(), 2) +
991 ':' + PadInt(this.getUTCMinutes(), 2) +
992 ':' + PadInt(this.getUTCSeconds(), 2) +
990 '.' + PadInt(this.getUTCMilliseconds(), 3) + 993 '.' + PadInt(this.getUTCMilliseconds(), 3) +
991 'Z'; 994 'Z';
992 } 995 }
993 996
994 997
995 function DateToJSON(key) { 998 function DateToJSON(key) {
996 return CheckJSONPrimitive(this.toISOString()); 999 var o = ToObject(this);
1000 var tv = DefaultNumber(o);
1001 if (IS_NUMBER(tv) && !$isFinite(tv)) {
1002 return null;
1003 }
1004 return o.toISOString();
997 } 1005 }
998 1006
999 1007
1000 // ------------------------------------------------------------------- 1008 // -------------------------------------------------------------------
1001 1009
1002 function SetupDate() { 1010 function SetupDate() {
1003 // Setup non-enumerable properties of the Date object itself. 1011 // Setup non-enumerable properties of the Date object itself.
1004 InstallFunctions($Date, DONT_ENUM, $Array( 1012 InstallFunctions($Date, DONT_ENUM, $Array(
1005 "UTC", DateUTC, 1013 "UTC", DateUTC,
1006 "parse", DateParse, 1014 "parse", DateParse,
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
1056 "toGMTString", DateToGMTString, 1064 "toGMTString", DateToGMTString,
1057 "toUTCString", DateToUTCString, 1065 "toUTCString", DateToUTCString,
1058 "getYear", DateGetYear, 1066 "getYear", DateGetYear,
1059 "setYear", DateSetYear, 1067 "setYear", DateSetYear,
1060 "toISOString", DateToISOString, 1068 "toISOString", DateToISOString,
1061 "toJSON", DateToJSON 1069 "toJSON", DateToJSON
1062 )); 1070 ));
1063 } 1071 }
1064 1072
1065 SetupDate(); 1073 SetupDate();
OLDNEW
« no previous file with comments | « no previous file | src/json.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698