summaryrefslogtreecommitdiff
path: root/deps/v8/src/dateparser-inl.h
diff options
context:
space:
mode:
Diffstat (limited to 'deps/v8/src/dateparser-inl.h')
-rw-r--r--deps/v8/src/dateparser-inl.h24
1 files changed, 14 insertions, 10 deletions
diff --git a/deps/v8/src/dateparser-inl.h b/deps/v8/src/dateparser-inl.h
index 8973aa0d4f..d405ab6493 100644
--- a/deps/v8/src/dateparser-inl.h
+++ b/deps/v8/src/dateparser-inl.h
@@ -23,9 +23,9 @@ bool DateParser::Parse(Vector<Char> str,
DayComposer day;
// Specification:
- // Accept ES6 ISO 8601 date-time-strings or legacy dates compatible
+ // Accept ES5 ISO 8601 date-time-strings or legacy dates compatible
// with Safari.
- // ES6 ISO 8601 dates:
+ // ES5 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 -
@@ -40,7 +40,8 @@ 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 local time if missing.
+ // timezone defaults to Z if missing
+ // (following Safari, ISO actually demands local time).
// Extensions:
// We also allow sss to have more or less than three digits (but at
// least one).
@@ -62,13 +63,15 @@ 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 ES6 date-time string.
- // After a valid "T" has been read while scanning an ES6 datetime string,
+ // 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,
// 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 ES6 Date Time String.
- DateToken next_unhandled_token = ParseES6DateTime(&scanner, &day, &time, &tz);
+ // First try getting as far as possible with as ES5 Date Time String.
+ DateToken next_unhandled_token = ParseES5DateTime(&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.
@@ -193,7 +196,7 @@ DateParser::DateToken DateParser::DateStringTokenizer<CharType>::Scan() {
template <typename Char>
-DateParser::DateToken DateParser::ParseES6DateTime(
+DateParser::DateToken DateParser::ParseES5DateTime(
DateStringTokenizer<Char>* scanner,
DayComposer* day,
TimeComposer* time,
@@ -231,7 +234,7 @@ DateParser::DateToken DateParser::ParseES6DateTime(
if (!scanner->Peek().IsKeywordType(TIME_SEPARATOR)) {
if (!scanner->Peek().IsEndOfInput()) return scanner->Next();
} else {
- // ES6 Date Time String time part is present.
+ // ES5 Date Time String time part is present.
scanner->Next();
if (!scanner->Peek().IsFixedLengthNumber(2) ||
!Between(scanner->Peek().number(), 0, 24)) {
@@ -297,7 +300,8 @@ DateParser::DateToken DateParser::ParseES6DateTime(
}
if (!scanner->Peek().IsEndOfInput()) return DateToken::Invalid();
}
- // Successfully parsed ES6 Date Time String.
+ // Successfully parsed ES5 Date Time String. Default to UTC if no TZ given.
+ if (tz->IsEmpty()) tz->Set(0);
day->set_iso_date();
return DateToken::EndOfInput();
}