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.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
« no previous file with comments | « src/date.js ('k') | src/dateparser.cc » ('j') | test/mjsunit/date-parse.js » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/dateparser.h
===================================================================
--- src/dateparser.h (revision 4543)
+++ src/dateparser.h (working copy)
@@ -44,13 +44,14 @@
// [3]: hour
// [4]: minute
// [5]: second
- // [6]: UTC offset in seconds, or null value if no timezone specified
+ // [6]: millisecond
+ // [7]: UTC offset in seconds, or null value if no timezone specified
// If parsing fails, return false (content of output array is not defined).
template <typename Char>
static bool Parse(Vector<Char> str, FixedArray* output);
enum {
- YEAR, MONTH, DAY, HOUR, MINUTE, SECOND, UTC_OFFSET, OUTPUT_SIZE
+ YEAR, MONTH, DAY, HOUR, MINUTE, SECOND, MILLISECOND, UTC_OFFSET, OUTPUT_SIZE
};
private:
@@ -189,7 +190,9 @@
TimeComposer() : index_(0), hour_offset_(kNone) {}
bool IsEmpty() const { return index_ == 0; }
bool IsExpecting(int n) const {
- return (index_ == 1 && IsMinute(n)) || (index_ == 2 && IsSecond(n));
+ return (index_ == 1 && IsMinute(n)) ||
+ (index_ == 2 && IsSecond(n)) ||
+ (index_ == 3 && IsMillisecond(n));
}
bool Add(int n) {
return index_ < kSize ? (comp_[index_++] = n, true) : false;
@@ -207,8 +210,9 @@
static bool IsHour(int x) { return Between(x, 0, 23); }
static bool IsHour12(int x) { return Between(x, 0, 12); }
static bool IsSecond(int x) { return Between(x, 0, 59); }
+ static bool IsMillisecond(int x) { return Between(x, 0, 999); }
- static const int kSize = 3;
+ static const int kSize = 4;
int comp_[kSize];
int index_;
int hour_offset_;
« no previous file with comments | « src/date.js ('k') | src/dateparser.cc » ('j') | test/mjsunit/date-parse.js » ('J')

Powered by Google App Engine
This is Rietveld 408576698