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

Unified Diff: src/dateparser-inl.h

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, 8 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 side-by-side diff with in-line comments
Download patch
Index: src/dateparser-inl.h
===================================================================
--- src/dateparser-inl.h (revision 4543)
+++ src/dateparser-inl.h (working copy)
@@ -54,16 +54,25 @@
} else {
// n + ":"
if (!time.Add(n)) return false;
+ in.Skip('.');
}
+ } else if (in.Skip('.') && time.IsExpecting(n)) {
+ time.Add(n);
+ if (!in.IsAsciiDigit()) return false;
+ int n = in.ReadUnsignedNumber();
+ time.AddFinal(n);
} else if (tz.IsExpecting(n)) {
tz.SetAbsoluteMinute(n);
} else if (time.IsExpecting(n)) {
time.AddFinal(n);
- // Require end or white space immediately after finalizing time.
- if (!in.IsEnd() && !in.SkipWhiteSpace()) return false;
+ // Require end, white space or Z immediately after finalizing time.
+ if (!in.IsEnd() && !in.SkipWhiteSpace() && !in.Is('Z')) return false;
} else {
if (!day.Add(n)) return false;
in.Skip('-'); // Ignore suffix '-' for year, month, or day.
+ // Skip trailing 'T' for ECMAScript 5 date string format but make
+ // sure that it is followed by a digit (for the time).
+ if (in.Skip('T') && !in.IsAsciiDigit()) return false;
}
} else if (in.IsAsciiAlphaOrAbove()) {
// Parse a "word" (sequence of chars. >= 'A').
« no previous file with comments | « src/dateparser.cc ('k') | test/mjsunit/date-parse.js » ('j') | test/mjsunit/date-parse.js » ('J')

Powered by Google App Engine
This is Rietveld 408576698