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

Unified Diff: src/dateparser-inl.h

Issue 1229903004: Make dates default to the local timezone if none specified (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Actually fix test Created 5 years, 5 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/dateparser.h ('k') | test/mjsunit/date.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/dateparser-inl.h
diff --git a/src/dateparser-inl.h b/src/dateparser-inl.h
index f7360f8c0231cc168a1c6cd64f3f1f355e9d97aa..fff14ea3aeb22bb0cc3c215994f44f7eaf93424a 100644
--- a/src/dateparser-inl.h
+++ b/src/dateparser-inl.h
@@ -22,9 +22,9 @@ bool DateParser::Parse(Vector<Char> str,
DayComposer day;
// Specification:
- // Accept ES5 ISO 8601 date-time-strings or legacy dates compatible
+ // Accept ES6 ISO 8601 date-time-strings or legacy dates compatible
// with Safari.
- // ES5 ISO 8601 dates:
+ // ES6 ISO 8601 dates:
// [('-'|'+')yy]yyyy[-MM[-DD]][THH:mm[:ss[.sss]][Z|(+|-)hh:mm]]
// where yyyy is in the range 0000..9999 and
// +/-yyyyyy is in the range -999999..+999999 -
@@ -39,8 +39,7 @@ bool DateParser::Parse(Vector<Char> str,
// sss is in the range 000..999,
// hh is in the range 00..23,
// mm, ss, and sss default to 00 if missing, and
- // timezone defaults to Z if missing
- // (following Safari, ISO actually demands local time).
+ // timezone defaults to local time if missing.
// Extensions:
// We also allow sss to have more or less than three digits (but at
// least one).
@@ -62,15 +61,13 @@ bool DateParser::Parse(Vector<Char> str,
// is allowed).
// Intersection of the two:
// A string that matches both formats (e.g. 1970-01-01) will be
- // parsed as an ES5 date-time string - which means it will default
- // to UTC time-zone. That's unavoidable if following the ES5
- // specification.
- // After a valid "T" has been read while scanning an ES5 datetime string,
+ // parsed as an ES6 date-time string.
+ // After a valid "T" has been read while scanning an ES6 datetime string,
// the input can no longer be a valid legacy date, since the "T" is a
// garbage string after a number has been read.
- // First try getting as far as possible with as ES5 Date Time String.
- DateToken next_unhandled_token = ParseES5DateTime(&scanner, &day, &time, &tz);
+ // First try getting as far as possible with as ES6 Date Time String.
+ DateToken next_unhandled_token = ParseES6DateTime(&scanner, &day, &time, &tz);
if (next_unhandled_token.IsInvalid()) return false;
bool has_read_number = !day.IsEmpty();
// If there's anything left, continue with the legacy parser.
@@ -195,7 +192,7 @@ DateParser::DateToken DateParser::DateStringTokenizer<CharType>::Scan() {
template <typename Char>
-DateParser::DateToken DateParser::ParseES5DateTime(
+DateParser::DateToken DateParser::ParseES6DateTime(
DateStringTokenizer<Char>* scanner,
DayComposer* day,
TimeComposer* time,
@@ -233,7 +230,7 @@ DateParser::DateToken DateParser::ParseES5DateTime(
if (!scanner->Peek().IsKeywordType(TIME_SEPARATOR)) {
if (!scanner->Peek().IsEndOfInput()) return scanner->Next();
} else {
- // ES5 Date Time String time part is present.
+ // ES6 Date Time String time part is present.
scanner->Next();
if (!scanner->Peek().IsFixedLengthNumber(2) ||
!Between(scanner->Peek().number(), 0, 24)) {
@@ -299,8 +296,7 @@ DateParser::DateToken DateParser::ParseES5DateTime(
}
if (!scanner->Peek().IsEndOfInput()) return DateToken::Invalid();
}
- // Successfully parsed ES5 Date Time String. Default to UTC if no TZ given.
- if (tz->IsEmpty()) tz->Set(0);
+ // Successfully parsed ES6 Date Time String.
day->set_iso_date();
return DateToken::EndOfInput();
}
« no previous file with comments | « src/dateparser.h ('k') | test/mjsunit/date.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698