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

Side by Side Diff: src/date.js

Issue 1704016: Added support for ES5 date time string format to Date.parse. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 10 years, 7 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 | src/dateparser.h » ('j') | test/mjsunit/date-parse.js » ('J')
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 602 matching lines...) Expand 10 before | Expand all | Expand 10 after
613 } 613 }
614 614
615 615
616 function DatePrintString(time) { 616 function DatePrintString(time) {
617 return DateString(time) + ' ' + TimeString(time); 617 return DateString(time) + ' ' + TimeString(time);
618 } 618 }
619 619
620 // ------------------------------------------------------------------- 620 // -------------------------------------------------------------------
621 621
622 // Reused output buffer. Used when parsing date strings. 622 // Reused output buffer. Used when parsing date strings.
623 var parse_buffer = $Array(7); 623 var parse_buffer = $Array(8);
624 624
625 // ECMA 262 - 15.9.4.2 625 // ECMA 262 - 15.9.4.2
626 function DateParse(string) { 626 function DateParse(string) {
627 var arr = %DateParseString(ToString(string), parse_buffer); 627 var arr = %DateParseString(ToString(string), parse_buffer);
628 if (IS_NULL(arr)) return $NaN; 628 if (IS_NULL(arr)) return $NaN;
629 629
630 var day = MakeDay(arr[0], arr[1], arr[2]); 630 var day = MakeDay(arr[0], arr[1], arr[2]);
631 var time = MakeTime(arr[3], arr[4], arr[5], 0); 631 var time = MakeTime(arr[3], arr[4], arr[5], arr[6]);
632 var date = MakeDate(day, time); 632 var date = MakeDate(day, time);
633 633
634 if (IS_NULL(arr[6])) { 634 if (IS_NULL(arr[7])) {
635 return TimeClip(UTC(date)); 635 return TimeClip(UTC(date));
636 } else { 636 } else {
637 return TimeClip(date - arr[6] * 1000); 637 return TimeClip(date - arr[7] * 1000);
638 } 638 }
639 } 639 }
640 640
641 641
642 // ECMA 262 - 15.9.4.3 642 // ECMA 262 - 15.9.4.3
643 function DateUTC(year, month, date, hours, minutes, seconds, ms) { 643 function DateUTC(year, month, date, hours, minutes, seconds, ms) {
644 year = ToNumber(year); 644 year = ToNumber(year);
645 month = ToNumber(month); 645 month = ToNumber(month);
646 var argc = %_ArgumentsLength(); 646 var argc = %_ArgumentsLength();
647 date = argc > 2 ? ToNumber(date) : 1; 647 date = argc > 2 ? ToNumber(date) : 1;
(...skipping 471 matching lines...) Expand 10 before | Expand all | Expand 10 after
1119 "toGMTString", DateToGMTString, 1119 "toGMTString", DateToGMTString,
1120 "toUTCString", DateToUTCString, 1120 "toUTCString", DateToUTCString,
1121 "getYear", DateGetYear, 1121 "getYear", DateGetYear,
1122 "setYear", DateSetYear, 1122 "setYear", DateSetYear,
1123 "toISOString", DateToISOString, 1123 "toISOString", DateToISOString,
1124 "toJSON", DateToJSON 1124 "toJSON", DateToJSON
1125 )); 1125 ));
1126 } 1126 }
1127 1127
1128 SetupDate(); 1128 SetupDate();
OLDNEW
« no previous file with comments | « no previous file | src/dateparser.h » ('j') | test/mjsunit/date-parse.js » ('J')

Powered by Google App Engine
This is Rietveld 408576698