Commit 093e68b4 authored by Frank Tang's avatar Frank Tang Committed by V8 LUCI CQ

[Temporal] Sync the Parser to the latest spec.

Add TimeHourMinuteBasicFormatNotAmbiguousWithMonthDay
TimeZoneNumericUTCOffsetNotAmbiguousWithDayOfMonth
TimeZoneNumericUTCOffsetNotAmbiguousWithMonth
TimeZoneIdentifier, UnpaddedHour, TimeZoneIANALegacyName productions.

Sync the spec of TemporalInstantString, TemporalTimeString
TimeZone, TimeZoneBracketedAnnotation, TemporalTimeZoneString,
ToTemporalTimeZone, TimeZoneIANAName productions.

Fix bug in ScanCalendarDateTimeTimeRequired, ToTemporalTimeZone

Change name from Handle<String> to Handle<Object> to hold undefined

Update parser tests accordingly.

Spec Text:
https://tc39.es/proposal-temporal/#sec-temporal-iso8601grammar
https://tc39.es/proposal-temporal/#sec-temporal-totemporaltimezone


Related PR changes:
https://github.com/tc39/proposal-temporal/pull/2284
https://github.com/tc39/proposal-temporal/pull/2287
https://github.com/tc39/proposal-temporal/pull/2345


Bug: v8:11544
Change-Id: I6f1a5e5dedba461db9f36abe76fa97119c1f8c2c
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3822342Reviewed-by: 's avatarShu-yu Guo <syg@chromium.org>
Commit-Queue: Frank Tang <ftang@chromium.org>
Cr-Commit-Position: refs/heads/main@{#83123}
parent b1a14770
......@@ -152,7 +152,7 @@ struct DateDurationRecord {
struct TimeZoneRecord {
bool z;
Handle<Object> offset_string; // String or Undefined
Handle<String> name;
Handle<Object> name; // String or Undefined
};
struct ZonedDateTimeRecord {
......@@ -3007,27 +3007,15 @@ MaybeHandle<JSReceiver> ToTemporalTimeZone(
Handle<JSReceiver>());
// 4. If parseResult.[[Name]] is not undefined, then
if (parse_result.name->length() > 0) {
if (!parse_result.name->IsUndefined()) {
DCHECK(parse_result.name->IsString());
// a. Let name be parseResult.[[Name]].
Handle<String> name = parse_result.name;
Handle<String> name = Handle<String>::cast(parse_result.name);
// b. If ParseText(StringToCodePoints(name, TimeZoneNumericUTCOffset)) is
// not a List of errors, then
// a List of errors, then
base::Optional<ParsedISO8601Result> parsed_offset =
TemporalParser::ParseTimeZoneNumericUTCOffset(isolate, name);
if (parsed_offset.has_value()) {
// i. If parseResult.[[OffsetString]] is not undefined, and !
// ParseTimeZoneOffsetString(parseResult.[[OffsetString]]) ≠ !
// ParseTimeZoneOffsetString(name), throw a RangeError exception.
if (!parse_result.offset_string->IsUndefined() &&
ParseTimeZoneOffsetString(
isolate, Handle<String>::cast(parse_result.offset_string))
.ToChecked() !=
ParseTimeZoneOffsetString(isolate, name).ToChecked()) {
THROW_NEW_ERROR(isolate, NEW_TEMPORAL_INVALID_ARG_RANGE_ERROR(),
JSReceiver);
}
// c. Else,
} else {
if (!parsed_offset.has_value()) {
// i. If ! IsValidTimeZoneName(name) is false, throw a RangeError
// exception.
if (!IsValidTimeZoneName(isolate, name)) {
......@@ -3036,10 +3024,9 @@ MaybeHandle<JSReceiver> ToTemporalTimeZone(
}
// ii. Set name to ! CanonicalizeTimeZoneName(name).
name = CanonicalizeTimeZoneName(isolate, name);
// d. Return ! CreateTemporalTimeZone(name).
return temporal::CreateTemporalTimeZone(isolate, name);
}
// c. Return ! CreateTemporalTimeZone(name).
return temporal::CreateTemporalTimeZone(isolate, name);
}
// 5. If parseResult.[[Z]] is true, return ! CreateTemporalTimeZone("UTC").
if (parse_result.z) {
......@@ -3654,6 +3641,7 @@ Maybe<ZonedDateTimeRecord> ParseTemporalRelativeToString(
// b. Let offsetString be undefined.
result.time_zone.offset_string = isolate->factory()->undefined_value();
// c. Let timeZone be undefined.
result.time_zone.name = isolate->factory()->undefined_value();
}
// 5. Return the Record { [[Year]]: result.[[Year]], [[Month]]:
// result.[[Month]], [[Day]]: result.[[Day]], [[Hour]]: result.[[Hour]],
......@@ -3932,7 +3920,7 @@ Maybe<TimeZoneRecord> ParseTemporalTimeZoneString(Isolate* isolate,
// productions, or undefined if not present.
// 4. If name is empty, then
// a. Set name to undefined.
Handle<String> name = isolate->factory()->empty_string();
Handle<Object> name = isolate->factory()->undefined_value();
// 5. Else,
// a. Set name to CodePointsToString(name).
if (parsed->tzi_name_length > 0) {
......@@ -8195,12 +8183,14 @@ MaybeHandle<Object> ToRelativeTemporalObject(Isolate* isolate,
offset_string_obj = result.time_zone.offset_string;
// e. Let timeZoneName be result.[[TimeZoneIANAName]].
Handle<String> time_zone_name = result.time_zone.name;
Handle<Object> time_zone_name_obj = result.time_zone.name;
// f. If timeZoneName is not undefined, then
if (!time_zone_name.is_null()) {
if (!time_zone_name_obj->IsUndefined()) {
// i. If ParseText(StringToCodePoints(timeZoneName),
// TimeZoneNumericUTCOffset) is a List of errors, then
DCHECK(time_zone_name_obj->IsString());
Handle<String> time_zone_name = Handle<String>::cast(time_zone_name_obj);
base::Optional<ParsedISO8601Result> parsed =
TemporalParser::ParseTimeZoneNumericUTCOffset(isolate,
time_zone_name);
......@@ -16066,8 +16056,8 @@ MaybeHandle<JSTemporalZonedDateTime> ToTemporalZonedDateTime(
Handle<JSTemporalZonedDateTime>());
// e. Assert: timeZoneName is not undefined.
Handle<String> time_zone_name = result.time_zone.name;
DCHECK(!time_zone_name.is_null());
DCHECK(!result.time_zone.name->IsUndefined());
Handle<String> time_zone_name = Handle<String>::cast(result.time_zone.name);
// f. If ParseText(StringToCodePoints(timeZoneName),
// TimeZoneNumericUTCOffset) is a List of errors, then
......
......@@ -126,6 +126,22 @@ int32_t ScanHour(base::Vector<Char> str, int32_t s, int32_t* out) {
return ScanTwoDigitsExpectRange<Char>(str, s, 0, 23, out);
}
// UnpaddedHour :
// DecimalDigit
// 1 DecimalDigit
// 20
// 21
// 22
// 23
template <typename Char>
int32_t ScanUnpaddedHour(base::Vector<Char> str, int32_t s) {
int32_t dummy;
int32_t len = ScanTwoDigitsExpectRange<Char>(str, s, 10, 23, &dummy);
if (len > 0) return len;
if (str.length() >= (s + 1) && IsDecimalDigit(str[s])) return 1;
return 0;
}
// MinuteSecond:
// [0 1 2 3 4 5] Digit
template <typename Char>
......@@ -366,83 +382,14 @@ int32_t ScanDate(base::Vector<Char> str, int32_t s, ParsedISO8601Result* r) {
return cur + len - s;
}
// TimeHourNotValidMonth : one of
// `00` `13` `14` `15` `16` `17` `18` `19` `20` `21` `23`
// DateMonthWithThirtyOneDays : one of
// 01 03 05 07 08 10 12
template <typename Char>
int32_t ScanTimeHourNotValidMonth(base::Vector<Char> str, int32_t s,
int32_t* out) {
return ScanTwoDigitsExpectZeroOrRange<Char>(str, s, 13, 23, out);
}
// TimeHourNotThirtyOneDayMonth : one of
// `02` `04` `06` `09` `11`
template <typename Char>
int32_t ScanTimeHourNotThirtyOneDayMonth(base::Vector<Char> str, int32_t s,
int32_t* out) {
return HasTwoDigits<Char>(str, s, out) &&
(*out == 2 || *out == 4 || *out == 6 || *out == 9 ||
*out == 11)
? 2
: 0;
}
// TimeHourTwoOnly : `02`
template <typename Char>
int32_t ScanTimeHourTwoOnly(base::Vector<Char> str, int32_t s, int32_t* out) {
return ScanTwoDigitsExpectValue<Char>(str, s, 2, out);
}
// TimeMinuteNotValidDay :
// `00`
// `32`
// `33`
// `34`
// `35`
// `36`
// `37`
// `38`
// `39`
// `4` DecimalDigit
// `5` DecimalDigit
// `60`
template <typename Char>
int32_t ScanTimeMinuteNotValidDay(base::Vector<Char> str, int32_t s,
int32_t* out) {
return ScanTwoDigitsExpectZeroOrRange<Char>(str, s, 32, 60, out);
}
// TimeMinuteThirtyOnly : `30`
template <typename Char>
int32_t ScanTimeMinuteThirtyOnly(base::Vector<Char> str, int32_t s,
int32_t* out) {
return ScanTwoDigitsExpectValue<Char>(str, s, 30, out);
}
// TimeMinuteThirtyOneOnly : `31`
template <typename Char>
int32_t ScanTimeMinuteThirtyOneOnly(base::Vector<Char> str, int32_t s,
int32_t* out) {
return ScanTwoDigitsExpectValue<Char>(str, s, 31, out);
}
// TimeSecondNotValidMonth :
// `00`
// `13`
// `14`
// `15`
// `16`
// `17`
// `18`
// `19`
// `2` DecimalDigit
// `3` DecimalDigit
// `4` DecimalDigit
// `5` DecimalDigit
// `60`
template <typename Char>
int32_t ScanTimeSecondNotValidMonth(base::Vector<Char> str, int32_t s,
int32_t* out) {
return ScanTwoDigitsExpectZeroOrRange<Char>(str, s, 13, 60, out);
int32_t ScanDateMonthWithThirtyOneDays(base::Vector<Char> str, int32_t s) {
int32_t value;
if (!HasTwoDigits(str, s, &value)) return false;
return value == 1 || value == 3 || value == 5 || value == 7 || value == 8 ||
value == 10 || value == 12;
}
// TimeZoneUTCOffsetHour: Hour
......@@ -471,13 +418,6 @@ int32_t ScanTimeZoneUTCOffsetFraction(base::Vector<Char> str, int32_t s,
return 0;
}
// We found the only difference between TimeZoneNumericUTCOffset and
// TimeZoneNumericUTCOffsetNotAmbiguous is ascii minus ('-') is not allowed in
// the production with only TimeZoneUTCOffsetHour for the case of
// TimeZoneNumericUTCOffsetNotAmbiguous.
// So we use the ScanTimeZoneNumericUTCOffset_Common template with an extra enum
// to implement both.
//
// TimeZoneNumericUTCOffset:
// TimeZoneUTCOffsetSign TimeZoneUTCOffsetHour
// TimeZoneUTCOffsetSign TimeZoneUTCOffsetHour : TimeZoneUTCOffsetMinute
......@@ -486,32 +426,19 @@ int32_t ScanTimeZoneUTCOffsetFraction(base::Vector<Char> str, int32_t s,
// TimeZoneUTCOffsetSecond [TimeZoneUTCOffsetFraction] TimeZoneUTCOffsetSign
// TimeZoneUTCOffsetHour TimeZoneUTCOffsetMinute TimeZoneUTCOffsetSecond
// [TimeZoneUTCOffsetFraction]
//
// TimeZoneNumericUTCOffsetNotAmbiguous :
// + TimeZoneUTCOffsetHour
// U+2212 TimeZoneUTCOffsetHour
// TimeZoneUTCOffsetSign TimeZoneUTCOffsetHour : TimeZoneUTCOffsetMinute
// TimeZoneUTCOffsetSign TimeZoneUTCOffsetHour TimeZoneUTCOffsetMinute
// TimeZoneUTCOffsetSign TimeZoneUTCOffsetHour : TimeZoneUTCOffsetMinute :
// TimeZoneUTCOffsetSecond [TimeZoneUTCOffsetFraction] TimeZoneUTCOffsetSign
// TimeZoneUTCOffsetHour TimeZoneUTCOffsetMinute TimeZoneUTCOffsetSecond
// [TimeZoneUTCOffsetFraction]
enum class Ambiguous { kAmbiguous, kNotAmbiguous };
template <typename Char>
int32_t ScanTimeZoneNumericUTCOffset_Common(base::Vector<Char> str, int32_t s,
ParsedISO8601Result* r,
Ambiguous ambiguous) {
int32_t ScanTimeZoneNumericUTCOffset(base::Vector<Char> str, int32_t s,
ParsedISO8601Result* r) {
int32_t len, hour, minute, second, nanosecond;
int32_t cur = s;
if ((str.length() < (cur + 1)) || (!IsTimeZoneUTCOffsetSign(str[cur]))) {
return 0;
}
bool sign_is_ascii_minus = str[s] == '-';
int32_t sign = (CanonicalSign(str[cur++]) == '-') ? -1 : 1;
if ((len = ScanTimeZoneUTCOffsetHour(str, cur, &hour)) == 0) return 0;
cur += len;
if ((cur + 1) > str.length()) {
if (ambiguous == Ambiguous::kNotAmbiguous && sign_is_ascii_minus) return 0;
// TimeZoneUTCOffsetSign TimeZoneUTCOffsetHour
r->tzuo_sign = sign;
r->tzuo_hour = hour;
......@@ -536,9 +463,6 @@ int32_t ScanTimeZoneNumericUTCOffset_Common(base::Vector<Char> str, int32_t s,
if ((len = ScanTimeZoneUTCOffsetSecond(str, cur, &second)) == 0) return 0;
} else {
if ((len = ScanTimeZoneUTCOffsetMinute(str, cur, &minute)) == 0) {
if (ambiguous == Ambiguous::kNotAmbiguous && sign_is_ascii_minus) {
return 0;
}
// TimeZoneUTCOffsetSign TimeZoneUTCOffsetHour
r->tzuo_sign = sign;
r->tzuo_hour = hour;
......@@ -570,68 +494,6 @@ int32_t ScanTimeZoneNumericUTCOffset_Common(base::Vector<Char> str, int32_t s,
return cur - s;
}
template <typename Char>
int32_t ScanTimeZoneNumericUTCOffset(base::Vector<Char> str, int32_t s,
ParsedISO8601Result* r) {
return ScanTimeZoneNumericUTCOffset_Common<Char>(str, s, r,
Ambiguous::kAmbiguous);
}
template <typename Char>
int32_t ScanTimeZoneNumericUTCOffsetNotAmbiguous(base::Vector<Char> str,
int32_t s,
ParsedISO8601Result* r) {
return ScanTimeZoneNumericUTCOffset_Common<Char>(str, s, r,
Ambiguous::kNotAmbiguous);
}
// TimeZoneNumericUTCOffsetNotAmbiguousAllowedNegativeHour :
// TimeZoneNumericUTCOffsetNotAmbiguous
// `-` TimeHourNotValidMonth
template <typename Char>
int32_t ScanTimeZoneNumericUTCOffsetNotAmbiguousAllowedNegativeHour(
base::Vector<Char> str, int32_t s, ParsedISO8601Result* r) {
int32_t len;
if ((len = ScanTimeZoneNumericUTCOffsetNotAmbiguous(str, s, r)) > 0) {
return len;
}
if (str.length() >= (s + 3) && str[s] == '-') {
int32_t time_hour;
len = ScanTimeHourNotValidMonth(str, s + 1, &time_hour);
if (len == 0) return 0;
r->time_hour = time_hour;
return 1 + len;
}
return 0;
}
// TimeHourMinuteBasicFormatNotAmbiguous :
// TimeHourNotValidMonth TimeMinute
// TimeHour TimeMinuteNotValidDay
// TimeHourNotThirtyOneDayMonth TimeMinuteThirtyOneOnly
// TimeHourTwoOnly TimeMinuteThirtyOnly
template <typename Char>
int32_t ScanTimeHourMinuteBasicFormatNotAmbiguous(base::Vector<Char> str,
int32_t s,
ParsedISO8601Result* r) {
int32_t time_hour, time_minute;
int32_t len1, len2;
if (((len1 = ScanTimeHourNotValidMonth(str, s, &time_hour)) > 0 &&
(len2 = ScanTimeMinute(str, s + len1, &time_minute)) > 0) ||
((len1 = ScanTimeHour(str, s, &time_hour)) > 0 &&
(len2 = ScanTimeMinuteNotValidDay(str, s + len1, &time_minute)) > 0) ||
((len1 = ScanTimeHourNotThirtyOneDayMonth(str, s, &time_hour)) > 0 &&
(len2 = ScanTimeMinuteThirtyOneOnly(str, s + len1, &time_minute)) > 0) ||
((len1 = ScanTimeHourTwoOnly(str, s, &time_hour)) > 0 &&
(len2 = ScanTimeMinuteThirtyOnly(str, s + len1, &time_minute)) > 0)) {
// Only set both after we got both
r->time_hour = time_hour;
r->time_minute = time_minute;
return len1 + len2;
}
return 0;
}
// TimeZoneUTCOffset:
// TimeZoneNumericUTCOffset
// UTCDesignator
......@@ -661,19 +523,88 @@ int32_t ScanTimeZoneIANANameComponent(base::Vector<Char> str, int32_t s) {
if ((cur - s) == 2 && str[s] == '.' && str[s + 1] == '.') return 0;
return cur - s;
}
// TimeZoneIANALegacyName :
// Etc/GMT0
// GMT0
// GMT-0
// GMT+0
// EST5EDT
// CST6CDT
// MST7MDT
// PST8PDT
template <typename Char>
int32_t ScanTimeZoneIANALegacyName(base::Vector<Char> str, int32_t s) {
int32_t cur = s;
{
constexpr int32_t len = 4;
if (str.length() < cur + len) return 0;
if (CompareCharsEqual(str.begin() + cur, "GMT0", len)) return len;
}
{
constexpr int32_t len = 5;
if (str.length() < cur + len) return 0;
if (CompareCharsEqual(str.begin() + cur, "GMT+0", len) ||
CompareCharsEqual(str.begin() + cur, "GMT-0", len)) {
return len;
}
}
{
constexpr int32_t len = 7;
if (str.length() < cur + len) return 0;
if (CompareCharsEqual(str.begin() + cur, "EST5EDT", len) ||
CompareCharsEqual(str.begin() + cur, "CST6CDT", len) ||
CompareCharsEqual(str.begin() + cur, "MST7MDT", len) ||
CompareCharsEqual(str.begin() + cur, "PST8PDT", len)) {
return len;
}
}
{
constexpr int32_t len = 8;
if (str.length() < cur + len) return 0;
if (CompareCharsEqual(str.begin() + cur, "Etc/GMT0", len)) return len;
}
return 0;
}
// Etc/GMT ASCIISign UnpaddedHour
template <typename Char>
int32_t ScanEtcGMTASCIISignUnpaddedHour(base::Vector<Char> str, int32_t s) {
if ((s + 9) > str.length()) return 0;
int32_t cur = s;
int32_t len = arraysize("Etc/GMT") - 1;
if (!CompareCharsEqual(str.begin() + cur, "Etc/GMT", len)) return 0;
cur += len;
Char sign = str[cur++];
if (!IsAsciiSign(sign)) return 0;
len = ScanUnpaddedHour(str, cur);
if (len == 0) return 0;
cur += len;
return cur - s;
}
// TimeZoneIANANameTail :
// TimeZoneIANANameComponent
// TimeZoneIANANameComponent / TimeZoneIANANameTail
// TimeZoneIANAName :
// Etc/GMT ASCIISign UnpaddedHour
// TimeZoneIANANameTail
// TimeZoneIANALegacyName
// The spec text use tail recusion with TimeZoneIANANameComponent and
// TimeZoneIANANameTail. In our implementation, we use an iteration loop
// instead.
template <typename Char>
int32_t ScanTimeZoneIANAName(base::Vector<Char> str, int32_t s) {
int32_t cur = s;
int32_t len;
if ((len = ScanEtcGMTASCIISignUnpaddedHour(str, s)) > 0 ||
(len = ScanTimeZoneIANALegacyName(str, s)) > 0) {
return len;
}
int32_t cur = s;
if ((len = ScanTimeZoneIANANameComponent(str, cur)) == 0) return 0;
cur += len;
while ((str.length() > (cur + 1)) && (str[cur] == '/')) {
......@@ -687,16 +618,6 @@ int32_t ScanTimeZoneIANAName(base::Vector<Char> str, int32_t s) {
return cur - s;
}
template <typename Char>
int32_t ScanTimeZoneIANAName(base::Vector<Char> str, int32_t s,
ParsedISO8601Result* r) {
int32_t len;
if ((len = ScanTimeZoneIANAName(str, s)) == 0) return 0;
r->tzi_name_start = s;
r->tzi_name_length = len;
return len;
}
// TimeZoneUTCOffsetName
// Sign Hour
// Sign Hour : MinuteSecond
......@@ -774,34 +695,21 @@ int32_t ScanEtcGMTAsciiSignHour(base::Vector<Char> str, int32_t s) {
}
template <typename Char>
int32_t ScanTimeZoneBracketedName(base::Vector<Char> str, int32_t s,
ParsedISO8601Result* r) {
int32_t len;
if ((len = ScanEtcGMTAsciiSignHour(str, s)) > 0) return len;
if ((len = ScanTimeZoneIANAName(str, s)) > 0) {
r->tzi_name_start = s;
r->tzi_name_length = len;
return len;
} else {
r->tzi_name_start = 0;
r->tzi_name_length = 0;
}
return ScanTimeZoneUTCOffsetName(str, s);
}
// TimeZoneBracketedAnnotation: '[' TimeZoneBracketedName ']'
int32_t ScanTimeZoneIdentifier(base::Vector<Char> str, int32_t s,
ParsedISO8601Result* r);
// TimeZoneBracketedAnnotation :
// [ TimeZoneIdentifier ]
template <typename Char>
int32_t ScanTimeZoneBracketedAnnotation(base::Vector<Char> str, int32_t s,
ParsedISO8601Result* r) {
if ((str.length() < (s + 3)) || (str[s] != '[')) return 0;
int32_t cur = s + 1;
cur += ScanTimeZoneBracketedName(str, cur, r);
if ((cur - s == 1) || str.length() < (cur + 1) || (str[cur++] != ']')) {
// Reset value setted by ScanTimeZoneBracketedName
r->tzi_name_start = 0;
r->tzi_name_length = 0;
int32_t len = ScanTimeZoneIdentifier(str, cur, r);
cur += len;
if (len == 0 || str.length() < (cur + 1) || (str[cur] != ']')) {
return 0;
}
cur++;
return cur - s;
}
......@@ -831,215 +739,95 @@ int32_t ScanTimeZoneNameRequired(base::Vector<Char> str, int32_t s,
}
// TimeZone:
// TimeZoneOffsetRequired
// TimeZoneNameRequired
// The lookahead is at most 1 char.
SCAN_EITHER_FORWARD(TimeZone, TimeZoneOffsetRequired, TimeZoneNameRequired,
ParsedISO8601Result)
// The defintion of TimeSpecWithOptionalTimeZoneNotAmbiguous is very complex. We
// break them down into 8 template with _L suffix.
// TimeSpecWithOptionalTimeZoneNotAmbiguous :
// TimeHour [TimeZoneNumericUTCOffsetNotAmbiguous]
// [TimeZoneBracketedAnnotation]
//
// TimeHourNotValidMonth TimeZone
//
// TimeHour : TimeMinute [TimeZone]
//
// TimeHourMinuteBasicFormatNotAmbiguous [TimeZoneBracketedAnnotation]
//
// TimeHour TimeMinute TimeZoneNumericUTCOffsetNotAmbiguousAllowedNegativeHour
// [TimeZoneBracketedAnnotation]
//
// TimeHour : TimeMinute : TimeSecond [TimeFraction] [TimeZone]
//
// TimeHour TimeMinute TimeSecondNotValidMonth [TimeZone]
//
// TimeHour TimeMinute TimeSecond TimeFraction [TimeZone]
//
// TimeSpecWithOptionalTimeZoneNotAmbiguous_L1:
// TimeHour [TimeZoneNumericUTCOffsetNotAmbiguous]
// [TimeZoneBracketedAnnotation]
template <typename Char>
int32_t ScanTimeSpecWithOptionalTimeZoneNotAmbiguous_L1(
base::Vector<Char> str, int32_t s, ParsedISO8601Result* r) {
int32_t time_hour;
int32_t cur = s;
int32_t len = ScanTimeHour(str, s, &time_hour);
if (len == 0) return 0;
cur += len;
r->time_hour = time_hour;
cur += ScanTimeZoneNumericUTCOffsetNotAmbiguous(str, cur, r);
cur += ScanTimeZoneBracketedAnnotation(str, cur, r);
return cur - s;
}
// TimeSpecWithOptionalTimeZoneNotAmbiguous_L2:
// TimeHourNotValidMonth TimeZone
template <typename Char>
int32_t ScanTimeSpecWithOptionalTimeZoneNotAmbiguous_L2(
base::Vector<Char> str, int32_t s, ParsedISO8601Result* r) {
int32_t time_hour;
int32_t cur = s;
int32_t len = ScanTimeHourNotValidMonth(str, s, &time_hour);
if (len == 0) return 0;
cur += len;
if ((len = ScanTimeZone(str, cur, r)) == 0) return 0;
// Set time_hour only after we have both.
r->time_hour = time_hour;
cur += len;
return cur - s;
}
// TimeSpecWithOptionalTimeZoneNotAmbiguous_L3:
// TimeHour : TimeMinute [TimeZone]
template <typename Char>
int32_t ScanTimeSpecWithOptionalTimeZoneNotAmbiguous_L3(
base::Vector<Char> str, int32_t s, ParsedISO8601Result* r) {
int32_t time_hour, time_minute;
// TimeHour
int32_t cur = s;
int32_t len = ScanTimeHour(str, s, &time_hour);
cur += len;
// :
if (str.length() < (cur + 3) || str[cur++] != ':') return 0;
// TimeMinute
if ((len = ScanTimeMinute(str, cur, &time_minute)) == 0) return 0;
// Set time_hour and time_minute only after we have both.
r->time_hour = time_hour;
r->time_minute = time_minute;
cur += len;
// [TimeZone]
cur += ScanTimeZone(str, cur, r);
return cur - s;
}
// TimeSpecWithOptionalTimeZoneNotAmbiguous_L4:
// TimeHourMinuteBasicFormatNotAmbiguous [TimeZoneBracketedAnnotation]
// TimeZoneUTCOffset [TimeZoneBracketedAnnotation]
// TimeZoneBracketedAnnotation
template <typename Char>
int32_t ScanTimeSpecWithOptionalTimeZoneNotAmbiguous_L4(
base::Vector<Char> str, int32_t s, ParsedISO8601Result* r) {
int32_t ScanTimeZone(base::Vector<Char> str, int32_t s,
ParsedISO8601Result* r) {
int32_t cur = s;
int32_t len = ScanTimeHourMinuteBasicFormatNotAmbiguous(str, cur, r);
if (len == 0) return 0;
cur += len;
cur += ScanTimeZoneBracketedAnnotation(str, cur, r);
return cur - s;
int32_t len;
// TimeZoneUTCOffset [TimeZoneBracketedAnnotation]
if ((len = ScanTimeZoneUTCOffset(str, cur, r)) > 0) {
cur += len;
// [TimeZoneBracketedAnnotation]
len = ScanTimeZoneBracketedAnnotation(str, cur, r);
cur += len;
return cur - s;
}
// TimeZoneBracketedAnnotation
return ScanTimeZoneBracketedAnnotation(str, cur, r);
}
// TimeSpecWithOptionalTimeZoneNotAmbiguous_L5:
// TimeHour TimeMinute TimeZoneNumericUTCOffsetNotAmbiguousAllowedNegativeHour
// [TimeZoneBracketedAnnotation]
// ValidMonthDay :
// DateMonth [-] 0 NonZeroDigit
// DateMonth [-] 1 DecimalDigit
// DateMonth [-] 2 DecimalDigit
// DateMonth [-] 30 but not one of 0230 or 02-30
// DateMonthWithThirtyOneDays [-] 31
template <typename Char>
int32_t ScanTimeSpecWithOptionalTimeZoneNotAmbiguous_L5(
base::Vector<Char> str, int32_t s, ParsedISO8601Result* r) {
int32_t time_hour, time_minute;
// TimeHour
int32_t ScanValidMonthDay(base::Vector<Char> str, int32_t s) {
int32_t len;
int32_t cur = s;
int32_t len = ScanTimeHour(str, s, &time_hour);
if (len == 0) return 0;
cur += len;
// TimeMinute
if ((len = ScanTimeMinute(str, cur, &time_minute)) == 0) return 0;
cur += len;
// TimeZoneNumericUTCOffsetNotAmbiguousAllowedNegativeHour
if ((len = ScanTimeZoneNumericUTCOffsetNotAmbiguousAllowedNegativeHour(
str, cur, r)) == 0)
return 0;
// Set time_hour and time_minute only after we have both.
r->time_hour = time_hour;
r->time_minute = time_minute;
cur += len;
// [TimeZoneBracketedAnnotation]
cur += ScanTimeZoneBracketedAnnotation(str, cur, r);
return cur - s;
int32_t date_month;
if ((len = ScanDateMonth(str, cur, &date_month)) > 0) {
cur += len;
if (str.length() >= (cur + 1)) {
if (str[cur] == '-') cur++;
int32_t day_of_month;
if ((len = ScanTwoDigitsExpectRange(str, cur, 1, 30, &day_of_month)) >
0) {
cur += len;
// 0 NonZeroDigit
// 1 DecimalDigit
// 2 DecimalDigit
// 30 but not one of 0230 or 02-30
if (date_month != 2 || day_of_month != 30) {
return cur - s;
}
}
}
}
// Reset cur
cur = s;
// DateMonthWithThirtyOneDays [-] 31
if ((len = ScanDateMonthWithThirtyOneDays(str, cur)) > 0) {
cur += len;
if (str.length() >= (cur + 1)) {
if (str[cur] == '-') cur++;
int32_t dummy;
if ((len = ScanTwoDigitsExpectValue(str, cur, 31, &dummy)) > 0) {
cur += len;
return cur - s;
}
}
}
return 0;
}
// TimeSpecWithOptionalTimeZoneNotAmbiguous_L6:
// TimeHour : TimeMinute : TimeSecond [TimeFraction] [TimeZone]
template <typename Char>
int32_t ScanTimeSpecWithOptionalTimeZoneNotAmbiguous_L6(
base::Vector<Char> str, int32_t s, ParsedISO8601Result* r) {
int32_t time_hour, time_minute, time_second;
// TimeHour
int32_t cur = s;
int32_t len = ScanTimeHour(str, s, &time_hour);
cur += len;
// :
if (str.length() < (cur + 3) || str[cur++] != ':') return 0;
// TimeMinute
if ((len = ScanTimeMinute(str, cur, &time_minute)) == 0) return 0;
cur += len;
// :
if (str.length() < (cur + 3) || str[cur++] != ':') return 0;
// TimeSecond
if ((len = ScanTimeSecond(str, cur, &time_second)) == 0) return 0;
cur += len;
// Set time_hour, time_minute, and time_second only after we have them all.
r->time_hour = time_hour;
r->time_minute = time_minute;
r->time_second = time_second;
// [TimeFraction]
cur += ScanTimeFraction(str, cur, r);
// [TimeZone]
cur += ScanTimeZone(str, cur, r);
return cur - s;
}
int32_t ScanDateSpecYearMonth(base::Vector<Char> str, int32_t s,
ParsedISO8601Result* r);
// TimeSpecWithOptionalTimeZoneNotAmbiguous_L7:
// TimeHour TimeMinute TimeSecondNotValidMonth [TimeZone]
// TimeSpecWithOptionalTimeZoneNotAmbiguous :
// TimeSpec [TimeZone] but not one of ValidMonthDay or DateSpecYearMonth
template <typename Char>
int32_t ScanTimeSpecWithOptionalTimeZoneNotAmbiguous_L7(
base::Vector<Char> str, int32_t s, ParsedISO8601Result* r) {
int32_t time_hour, time_minute, time_second;
// TimeHour
int32_t ScanTimeSpecWithOptionalTimeZoneNotAmbiguous(base::Vector<Char> str,
int32_t s,
ParsedISO8601Result* r) {
int32_t cur = s;
int32_t len = ScanTimeHour(str, s, &time_hour);
if (len == 0) return 0;
cur += len;
// TimeMinute
if ((len = ScanTimeMinute(str, cur, &time_minute)) == 0) return 0;
cur += len;
// TimeSecondNotValidMonth
if ((len = ScanTimeSecondNotValidMonth(str, cur, &time_second)) == 0)
return 0;
int32_t len;
if ((len = ScanTimeSpec(str, cur, r)) == 0) return 0;
cur += len;
// Set time_hour, time_minute, and time_second only after we have them all.
r->time_hour = time_hour;
r->time_minute = time_minute;
r->time_second = time_second;
// [TimeZone]
cur += ScanTimeZone(str, cur, r);
return cur - s;
}
// TimeSpecWithOptionalTimeZoneNotAmbiguous_L8:
// TimeHour TimeMinute TimeSecond TimeFraction [TimeZone]
template <typename Char>
int32_t ScanTimeSpecWithOptionalTimeZoneNotAmbiguous_L8(
base::Vector<Char> str, int32_t s, ParsedISO8601Result* r) {
int32_t time_hour, time_minute, time_second;
// TimeHour
int32_t cur = s;
int32_t len = ScanTimeHour(str, s, &time_hour);
cur += len;
// TimeMinute
if ((len = ScanTimeMinute(str, cur, &time_minute)) == 0) return 0;
cur += len;
// TimeSecond
if ((len = ScanTimeSecond(str, cur, &time_second)) == 0) return 0;
cur += len;
// TimeFraction
if ((len = ScanTimeFraction(str, cur, r)) == 0) return 0;
len = ScanTimeZone(str, cur, r);
cur += len;
// Set time_hour, time_minute, and time_second only after we have them all.
r->time_hour = time_hour;
r->time_minute = time_minute;
r->time_second = time_second;
// [TimeZone]
cur += ScanTimeZone(str, cur, r);
return cur - s;
len = cur - s;
// If it match ValidMonthDay, consider invalid.
if (ScanValidMonthDay(str, s) == len) return 0;
// If it match DateSpecYearMonth, consider invalid.
ParsedISO8601Result tmp;
if (ScanDateSpecYearMonth(str, s, &tmp) == len) return 0;
return len;
}
// CalendarNameComponent:
......@@ -1115,18 +903,16 @@ int32_t ScanCalendarTime_L1(base::Vector<Char> str, int32_t s,
}
// CalendarTime_L2 :
// TimeSpec [TimeZone] Calendar
// TimeSpecWithOptionalTimeZoneNotAmbiguous [Calendar]
template <typename Char>
int32_t ScanCalendarTime_L2(base::Vector<Char> str, int32_t s,
ParsedISO8601Result* r) {
int32_t cur = s;
int32_t len = ScanTimeSpec(str, cur, r);
int32_t len = ScanTimeSpecWithOptionalTimeZoneNotAmbiguous(str, cur, r);
if (len == 0) return 0;
cur += len;
// [TimeZone]
cur += ScanTimeZone(str, cur, r);
if ((len = ScanCalendar(str, cur, r)) == 0) return 0;
cur += len;
// [Calendar]
cur += ScanCalendar(str, cur, r);
return cur - s;
}
......@@ -1163,7 +949,7 @@ int32_t ScanDateSpecYearMonth(base::Vector<Char> str, int32_t s,
}
// DateSpecMonthDay:
// TwoDashopt DateMonth -opt DateDay
// [TwoDash] DateMonth [-] DateDay
template <typename Char>
int32_t ScanDateSpecMonthDay(base::Vector<Char> str, int32_t s,
ParsedISO8601Result* r) {
......@@ -1190,18 +976,22 @@ int32_t ScanDateSpecMonthDay(base::Vector<Char> str, int32_t s,
return cur - s;
}
// TemporalTimeZoneIdentifier:
// TimeZoneNumericUTCOffset
// TimeZoneIdentifier :
// TimeZoneIANAName
// TimeZoneUTCOffsetName
template <typename Char>
int32_t ScanTemporalTimeZoneIdentifier(base::Vector<Char> str, int32_t s,
ParsedISO8601Result* r) {
int32_t ScanTimeZoneIdentifier(base::Vector<Char> str, int32_t s,
ParsedISO8601Result* r) {
int32_t len;
if ((len = ScanTimeZoneNumericUTCOffset(str, s, r)) > 0) return len;
if ((len = ScanTimeZoneIANAName(str, s)) == 0) return 0;
r->tzi_name_start = s;
r->tzi_name_length = len;
return len;
int32_t cur = s;
if ((len = ScanTimeZoneIANAName(str, cur)) > 0 ||
(len = ScanTimeZoneUTCOffsetName(str, cur)) > 0) {
cur += len;
r->tzi_name_start = s;
r->tzi_name_length = len;
return cur - s;
}
return 0;
}
// CalendarDateTime: DateTime [Calendar]
......@@ -1257,8 +1047,6 @@ int32_t ScanTemporalZonedDateTimeString(base::Vector<Char> str, int32_t s,
SCAN_FORWARD(TemporalDateTimeString, CalendarDateTime, ParsedISO8601Result)
// TemporalTimeZoneString:
// TemporalTimeZoneIdentifier
// Date [TimeSpecSeparator] TimeZone [Calendar]
template <typename Char>
int32_t ScanDate_TimeSpecSeparator_TimeZone_Calendar(base::Vector<Char> str,
......@@ -1276,25 +1064,14 @@ int32_t ScanDate_TimeSpecSeparator_TimeZone_Calendar(base::Vector<Char> str,
return cur - s;
}
// TemporalTimeZoneString:
// TimeZoneIdentifier
// Date [TimeSpecSeparator] TimeZone [Calendar]
// The lookahead is at most 8 chars.
SCAN_EITHER_FORWARD(TemporalTimeZoneString, TemporalTimeZoneIdentifier,
SCAN_EITHER_FORWARD(TemporalTimeZoneString, TimeZoneIdentifier,
Date_TimeSpecSeparator_TimeZone_Calendar,
ParsedISO8601Result)
// TemporalTimeString
// CalendarTime
// CalendarDateTimeTimeRequired
// The lookahead is at most 7 chars.
SCAN_EITHER_FORWARD(TemporalTimeString, CalendarTime,
CalendarDateTimeTimeRequired, ParsedISO8601Result)
// TemporalYearMonthString:
// DateSpecYearMonth
// CalendarDateTime
// The lookahead is at most 11 chars.
SCAN_EITHER_FORWARD(TemporalYearMonthString, DateSpecYearMonth,
CalendarDateTime, ParsedISO8601Result)
// TemporalMonthDayString
// DateSpecMonthDay
// CalendarDateTime
......@@ -1303,8 +1080,7 @@ SCAN_EITHER_FORWARD(TemporalMonthDayString, DateSpecMonthDay, CalendarDateTime,
ParsedISO8601Result)
// TemporalInstantString
// Date TimeZoneOffsetRequired
// Date DateTimeSeparator TimeSpec TimeZoneOffsetRequired
// Date [TimeSpecSeparator] TimeZoneOffsetRequired [Calendar]
template <typename Char>
int32_t ScanTemporalInstantString(base::Vector<Char> str, int32_t s,
ParsedISO8601Result* r) {
......@@ -1314,26 +1090,15 @@ int32_t ScanTemporalInstantString(base::Vector<Char> str, int32_t s,
if (len == 0) return 0;
cur += len;
// TimeZoneOffsetRequired
len = ScanTimeZoneOffsetRequired(str, cur, r);
if (len > 0) {
cur += len;
return cur - s;
}
// DateTimeSeparator
if (!(((cur + 1) < str.length()) && IsDateTimeSeparator(str[cur++]))) {
return 0;
}
// TimeSpec
len = ScanTimeSpec(str, cur, r);
if (len == 0) return 0;
cur += len;
// [TimeSpecSeparator]
cur += ScanTimeSpecSeparator(str, cur, r);
// TimeZoneOffsetRequired
len = ScanTimeZoneOffsetRequired(str, cur, r);
if (len == 0) return 0;
cur += len;
// [Calendar]
cur += ScanCalendar(str, cur, r);
return cur - s;
}
......@@ -1371,51 +1136,36 @@ SATISIFY(Date_TimeSpecSeparator_TimeZone_Calendar, ParsedISO8601Result)
SATISIFY(CalendarDateTime, ParsedISO8601Result)
SATISIFY(CalendarTime_L1, ParsedISO8601Result)
SATISIFY(CalendarTime_L2, ParsedISO8601Result)
SATISIFY(TimeSpecWithOptionalTimeZoneNotAmbiguous_L1, ParsedISO8601Result)
SATISIFY(TimeSpecWithOptionalTimeZoneNotAmbiguous_L2, ParsedISO8601Result)
SATISIFY(TimeSpecWithOptionalTimeZoneNotAmbiguous_L3, ParsedISO8601Result)
SATISIFY(TimeSpecWithOptionalTimeZoneNotAmbiguous_L4, ParsedISO8601Result)
SATISIFY(TimeSpecWithOptionalTimeZoneNotAmbiguous_L5, ParsedISO8601Result)
SATISIFY(TimeSpecWithOptionalTimeZoneNotAmbiguous_L6, ParsedISO8601Result)
SATISIFY(TimeSpecWithOptionalTimeZoneNotAmbiguous_L7, ParsedISO8601Result)
SATISIFY(TimeSpecWithOptionalTimeZoneNotAmbiguous_L8, ParsedISO8601Result)
template <typename Char>
bool SatisfyTimeSpecWithOptionalTimeZoneNotAmbiguous(base::Vector<Char> str,
ParsedISO8601Result* r) {
IF_SATISFY_RETURN(TimeSpecWithOptionalTimeZoneNotAmbiguous_L1)
IF_SATISFY_RETURN(TimeSpecWithOptionalTimeZoneNotAmbiguous_L2)
IF_SATISFY_RETURN(TimeSpecWithOptionalTimeZoneNotAmbiguous_L3)
IF_SATISFY_RETURN(TimeSpecWithOptionalTimeZoneNotAmbiguous_L4)
IF_SATISFY_RETURN(TimeSpecWithOptionalTimeZoneNotAmbiguous_L5)
IF_SATISFY_RETURN(TimeSpecWithOptionalTimeZoneNotAmbiguous_L6)
IF_SATISFY_RETURN(TimeSpecWithOptionalTimeZoneNotAmbiguous_L7)
IF_SATISFY_RETURN(TimeSpecWithOptionalTimeZoneNotAmbiguous_L8)
return false;
}
template <typename Char>
bool SatisfyCalendarTime(base::Vector<Char> str, ParsedISO8601Result* r) {
IF_SATISFY_RETURN(CalendarTime_L1)
IF_SATISFY_RETURN(CalendarTime_L2)
IF_SATISFY_RETURN(TimeSpecWithOptionalTimeZoneNotAmbiguous)
return false;
}
SATISIFY_EITHER(TemporalTimeString, CalendarTime, CalendarDateTime,
SATISIFY(CalendarDateTimeTimeRequired, ParsedISO8601Result)
SATISIFY_EITHER(TemporalTimeString, CalendarTime, CalendarDateTimeTimeRequired,
ParsedISO8601Result)
SATISIFY_EITHER(TemporalYearMonthString, DateSpecYearMonth, CalendarDateTime,
ParsedISO8601Result)
SATISIFY_EITHER(TemporalMonthDayString, DateSpecMonthDay, CalendarDateTime,
ParsedISO8601Result)
SATISIFY(TimeZoneNumericUTCOffset, ParsedISO8601Result)
SATISIFY(TimeZoneIANAName, ParsedISO8601Result)
SATISIFY_EITHER(TemporalTimeZoneIdentifier, TimeZoneNumericUTCOffset,
TimeZoneIANAName, ParsedISO8601Result)
SATISIFY_EITHER(TemporalTimeZoneString, TemporalTimeZoneIdentifier,
SATISIFY(TimeZoneIdentifier, ParsedISO8601Result)
SATISIFY_EITHER(TemporalTimeZoneString, TimeZoneIdentifier,
Date_TimeSpecSeparator_TimeZone_Calendar, ParsedISO8601Result)
SATISIFY(TemporalInstantString, ParsedISO8601Result)
SATISIFY(TemporalZonedDateTimeString, ParsedISO8601Result)
SATISIFY(CalendarName, ParsedISO8601Result)
// TemporalCalendarString :
// CalendarName
// TemporalInstantString
// CalendarDateTime
// CalendarTime
// DateSpecYearMonth
// DateSpecMonthDay
template <typename Char>
bool SatisfyTemporalCalendarString(base::Vector<Char> str,
ParsedISO8601Result* r) {
......
......@@ -444,63 +444,15 @@
# https://github.com/tc39/proposal-temporal/pull/1862
'built-ins/Temporal/Duration/prototype/total/timezone-getpossibleinstantsfor-iterable': [FAIL],
# TimeZone name test should move to intl402
# https://github.com/tc39/test262/issues/3253
'built-ins/Temporal/Duration/prototype/add/relativeto-string-datetime': [FAIL],
'built-ins/Temporal/Duration/prototype/subtract/relativeto-string-datetime': [FAIL],
# precision
'built-ins/Temporal/Duration/prototype/total/relativeto-string-datetime': [FAIL],
# https://bugs.chromium.org/p/v8/issues/detail?id=11544
'built-ins/Temporal/Calendar/prototype/weekOfYear/calendar-datefromfields-called-with-options-undefined': [FAIL],
'built-ins/Temporal/Duration/compare/relativeto-sub-minute-offset': [FAIL],
'built-ins/Temporal/Duration/prototype/add/relativeto-sub-minute-offset': [FAIL],
'built-ins/Temporal/Duration/prototype/round/relativeto-string-datetime': [FAIL],
'built-ins/Temporal/Duration/prototype/round/relativeto-sub-minute-offset': [FAIL],
'built-ins/Temporal/Duration/prototype/subtract/relativeto-sub-minute-offset': [FAIL],
'built-ins/Temporal/Duration/prototype/total/balance-negative-result': [FAIL],
'built-ins/Temporal/Duration/prototype/total/relativeto-sub-minute-offset': [FAIL],
'built-ins/Temporal/Instant/prototype/toZonedDateTimeISO/timezone-string-multiple-offsets': [FAIL],
'built-ins/Temporal/Instant/prototype/toZonedDateTime/timezone-string-multiple-offsets': [FAIL],
'built-ins/Temporal/Now/zonedDateTimeISO/timezone-string-multiple-offsets': [FAIL],
'built-ins/Temporal/Now/zonedDateTime/timezone-string-multiple-offsets': [FAIL],
'built-ins/Temporal/PlainDate/prototype/toZonedDateTime/timezone-string-multiple-offsets': [FAIL],
'built-ins/Temporal/PlainDateTime/prototype/toZonedDateTime/timezone-string-multiple-offsets': [FAIL],
'built-ins/Temporal/PlainTime/prototype/toZonedDateTime/timezone-string-multiple-offsets': [FAIL],
'built-ins/Temporal/TimeZone/from/timezone-string-multiple-offsets': [FAIL],
'built-ins/Temporal/ZonedDateTime/compare/zoneddatetime-string': [FAIL],
'built-ins/Temporal/ZonedDateTime/compare/zoneddatetime-string-multiple-offsets': [FAIL],
'built-ins/Temporal/ZonedDateTime/from/timezone-string-multiple-offsets': [FAIL],
'built-ins/Temporal/ZonedDateTime/from/zoneddatetime-string': [FAIL],
'built-ins/Temporal/ZonedDateTime/from/zoneddatetime-string-multiple-offsets': [FAIL],
'built-ins/Temporal/ZonedDateTime/from/zoneddatetime-sub-minute-offset': [FAIL],
'built-ins/Temporal/ZonedDateTime/prototype/equals/sub-minute-offset': [FAIL],
'built-ins/Temporal/ZonedDateTime/prototype/equals/timezone-string-datetime': [SKIP],
'built-ins/Temporal/ZonedDateTime/prototype/equals/timezone-string-multiple-offsets': [FAIL],
'built-ins/Temporal/ZonedDateTime/prototype/equals/zoneddatetime-string': [FAIL],
'built-ins/Temporal/ZonedDateTime/prototype/equals/zoneddatetime-string-multiple-offsets': [FAIL],
'built-ins/Temporal/ZonedDateTime/prototype/since/sub-minute-offset': [FAIL],
'built-ins/Temporal/ZonedDateTime/prototype/since/zoneddatetime-string': [FAIL],
'built-ins/Temporal/ZonedDateTime/prototype/since/zoneddatetime-string-multiple-offsets': [FAIL],
'built-ins/Temporal/ZonedDateTime/prototype/until/sub-minute-offset': [FAIL],
'built-ins/Temporal/ZonedDateTime/prototype/until/zoneddatetime-string': [FAIL],
'built-ins/Temporal/ZonedDateTime/prototype/until/zoneddatetime-string-multiple-offsets': [FAIL],
'built-ins/Temporal/ZonedDateTime/prototype/withTimeZone/timezone-string-multiple-offsets': [FAIL],
'intl402/Temporal/Calendar/prototype/dateFromFields/infinity-throws-rangeerror': [FAIL],
'intl402/Temporal/Calendar/prototype/monthDayFromFields/infinity-throws-rangeerror': [FAIL],
'intl402/Temporal/Calendar/prototype/yearMonthFromFields/infinity-throws-rangeerror': [FAIL],
'intl402/Temporal/Duration/prototype/round/relativeto-string-datetime': [FAIL],
'intl402/Temporal/Duration/prototype/total/relativeto-string-datetime': [FAIL],
'intl402/Temporal/PlainYearMonth/from/argument-object': [FAIL],
'built-ins/Temporal/PlainDate/prototype/toPlainDateTime/argument-string-no-implicit-midnight': [FAIL],
'built-ins/Temporal/PlainDate/prototype/toZonedDateTime/argument-string-no-implicit-midnight': [FAIL],
'built-ins/Temporal/PlainDateTime/prototype/withPlainTime/argument-string-no-implicit-midnight': [FAIL],
'built-ins/Temporal/PlainTime/compare/argument-string-no-implicit-midnight': [FAIL],
'built-ins/Temporal/PlainTime/from/argument-string-no-implicit-midnight': [FAIL],
'built-ins/Temporal/PlainTime/prototype/since/argument-string-no-implicit-midnight': [FAIL],
'built-ins/Temporal/PlainTime/prototype/until/argument-string-no-implicit-midnight': [FAIL],
'built-ins/Temporal/ZonedDateTime/prototype/withPlainTime/argument-string-no-implicit-midnight': [FAIL],
'built-ins/Temporal/Instant/prototype/round/rounding-direction': [FAIL],
'built-ins/Temporal/Instant/prototype/toString/rounding-direction': [FAIL],
......@@ -575,21 +527,16 @@
'built-ins/Temporal/Duration/prototype/subtract/relativeto-propertybag-calendar-number': [FAIL],
'built-ins/Temporal/Duration/prototype/total/relativeto-propertybag-calendar-number': [FAIL],
'built-ins/Temporal/ZonedDateTime/timezone-string-multiple-offsets': [FAIL],
'built-ins/Temporal/Duration/prototype/add/relativeto-year': [FAIL],
'built-ins/Temporal/Instant/from/argument-string': [FAIL],
'intl402/Temporal/Calendar/prototype/dateFromFields/order-of-operations': [FAIL],
'intl402/Temporal/Calendar/prototype/monthDayFromFields/order-of-operations': [FAIL],
'intl402/Temporal/Calendar/prototype/yearMonthFromFields/order-of-operations': [FAIL],
'intl402/Temporal/Duration/compare/relativeto-hour': [FAIL],
'built-ins/Temporal/PlainTime/prototype/equals/argument-string-no-implicit-midnight': [FAIL],
'built-ins/Temporal/Duration/prototype/total/relativeto-zoneddatetime-with-fractional-days-different-sign': [FAIL],
'built-ins/Temporal/Duration/prototype/total/relativeto-zoneddatetime-with-fractional-days': [FAIL],
'intl402/Temporal/TimeZone/prototype/getNextTransition/subtract-second-and-nanosecond-from-last-transition': [FAIL],
'intl402/Temporal/TimeZone/prototype/getPreviousTransition/nanoseconds-subtracted-or-added-at-dst-transition': [FAIL],
'intl402/Temporal/TimeZone/from/etc-timezone': [FAIL],
'intl402/Temporal/TimeZone/from/iana-legacy-names': [FAIL],
'intl402/Temporal/TimeZone/prototype/getNextTransition/transition-at-instant-boundaries': [FAIL],
'intl402/Temporal/TimeZone/prototype/getOffsetNanosecondsFor/nanoseconds-subtracted-or-added-at-dst-transition': [FAIL],
'intl402/Temporal/TimeZone/prototype/getPlainDateTimeFor/dst': [FAIL],
......@@ -624,16 +571,6 @@
'harness/temporalHelpers-one-shift-time-zone': [SKIP],
'built-ins/Temporal/Instant/compare/instant-string': [FAIL],
'built-ins/Temporal/Instant/from/instant-string': [FAIL],
'built-ins/Temporal/Instant/prototype/equals/instant-string': [FAIL],
'built-ins/Temporal/Instant/prototype/since/instant-string': [FAIL],
'built-ins/Temporal/Instant/prototype/until/instant-string': [FAIL],
'built-ins/Temporal/TimeZone/prototype/getNextTransition/instant-string': [FAIL],
'built-ins/Temporal/TimeZone/prototype/getOffsetNanosecondsFor/instant-string': [FAIL],
'built-ins/Temporal/TimeZone/prototype/getOffsetStringFor/instant-string': [FAIL],
'built-ins/Temporal/TimeZone/prototype/getPlainDateTimeFor/instant-string': [FAIL],
'built-ins/Temporal/TimeZone/prototype/getPreviousTransition/instant-string': [FAIL],
'staging/Intl402/Temporal/old/addition-across-lunisolar-leap-months': [FAIL],
'staging/Intl402/Temporal/old/date-time-format': [FAIL],
'staging/Intl402/Temporal/old/datetime-toLocaleString': [FAIL],
......
......@@ -77,16 +77,18 @@ char asciitolower(char in) {
return (in <= 'Z' && in >= 'A') ? (in - ('Z' - 'z')) : in;
}
#define IMPL_VERIFY_PARSE_TEMPORAL_DATE_STRING_SUCCESS(R) \
void VerifyParseTemporal##R##StringSuccess( \
const char* str, int32_t date_year, int32_t date_month, \
int32_t date_day, const char* calendar_name) { \
Handle<String> input = MakeString(str); \
ParsedISO8601Result actual = \
*TemporalParser::ParseTemporal##R##String(i_isolate(), input); \
CheckDate(actual, date_year, date_month, date_day); \
CheckCalendar(i_isolate(), input, actual.calendar_name_start, \
actual.calendar_name_length, calendar_name); \
#define IMPL_VERIFY_PARSE_TEMPORAL_DATE_STRING_SUCCESS(R) \
void VerifyParseTemporal##R##StringSuccess( \
const char* str, int32_t date_year, int32_t date_month, \
int32_t date_day, const char* calendar_name) { \
Handle<String> input = MakeString(str); \
base::Optional<ParsedISO8601Result> result = \
TemporalParser::ParseTemporal##R##String(i_isolate(), input); \
CHECK(result.has_value()); \
ParsedISO8601Result actual = *result; \
CheckDate(actual, date_year, date_month, date_day); \
CheckCalendar(i_isolate(), input, actual.calendar_name_start, \
actual.calendar_name_length, calendar_name); \
}
#define IMPL_VERIFY_PARSE_TEMPORAL_DATE_TIME_STRING_SUCCESS(R) \
......@@ -96,8 +98,10 @@ char asciitolower(char in) {
int32_t time_second, int32_t time_nanosecond, \
const char* calendar_name) { \
Handle<String> input = MakeString(str); \
ParsedISO8601Result actual = \
*TemporalParser::ParseTemporal##R##String(i_isolate(), input); \
base::Optional<ParsedISO8601Result> result = \
TemporalParser::ParseTemporal##R##String(i_isolate(), input); \
CHECK(result.has_value()); \
ParsedISO8601Result actual = *result; \
CheckDate(actual, date_year, date_month, date_day); \
CheckCalendar(i_isolate(), input, actual.calendar_name_start, \
actual.calendar_name_length, calendar_name); \
......@@ -113,8 +117,10 @@ char asciitolower(char in) {
int32_t tzuo_second, int32_t tzuo_nanosecond, bool utc_designator, \
const char* tzi_name) { \
Handle<String> input = MakeString(str); \
ParsedISO8601Result actual = \
*TemporalParser::ParseTemporal##R##String(i_isolate(), input); \
base::Optional<ParsedISO8601Result> result = \
TemporalParser::ParseTemporal##R##String(i_isolate(), input); \
CHECK(result.has_value()); \
ParsedISO8601Result actual = *result; \
CheckDate(actual, date_year, date_month, date_day); \
CheckCalendar(i_isolate(), input, actual.calendar_name_start, \
actual.calendar_name_length, calendar_name); \
......@@ -141,8 +147,10 @@ class TemporalParserTest : public TestWithIsolate {
int32_t tzuo_hour, int32_t tzuo_minute, int32_t tzuo_second,
int32_t tzuo_nanosecond) {
Handle<String> input = MakeString(str);
ParsedISO8601Result actual =
*TemporalParser::ParseTemporalInstantString(i_isolate(), input);
base::Optional<ParsedISO8601Result> result =
TemporalParser::ParseTemporalInstantString(i_isolate(), input);
CHECK(result.has_value());
ParsedISO8601Result actual = *result;
CHECK_EQ(utc_designator, actual.utc_designator);
if (!utc_designator) {
CheckTimeZoneNumericUTCOffset(actual, tzuo_sign, tzuo_hour, tzuo_minute,
......@@ -153,8 +161,10 @@ class TemporalParserTest : public TestWithIsolate {
void VerifyParseTemporalCalendarStringSuccess(
const char* str, const std::string& calendar_name) {
Handle<String> input = MakeString(str);
ParsedISO8601Result actual =
*TemporalParser::ParseTemporalCalendarString(i_isolate(), input);
base::Optional<ParsedISO8601Result> result =
TemporalParser::ParseTemporalCalendarString(i_isolate(), input);
CHECK(result.has_value());
ParsedISO8601Result actual = *result;
CheckCalendar(i_isolate(), input, actual.calendar_name_start,
actual.calendar_name_length, calendar_name);
}
......@@ -185,10 +195,12 @@ class TemporalParserTest : public TestWithIsolate {
int64_t whole_seconds,
int64_t seconds_fraction) {
Handle<String> input = MakeString(str);
CheckDuration(
*TemporalParser::ParseTemporalDurationString(i_isolate(), input), sign,
years, months, weeks, days, whole_hours, hours_fraction, whole_minutes,
minutes_fraction, whole_seconds, seconds_fraction);
base::Optional<ParsedISO8601Duration> result =
TemporalParser::ParseTemporalDurationString(i_isolate(), input);
CHECK(result.has_value());
CheckDuration(*result, sign, years, months, weeks, days, whole_hours,
hours_fraction, whole_minutes, minutes_fraction,
whole_seconds, seconds_fraction);
}
void VerifyParseDurationSuccess(const char* str,
......@@ -202,8 +214,10 @@ class TemporalParserTest : public TestWithIsolate {
void VerifyParseDurationWithPositiveSign(const char* str) {
Handle<String> input = MakeString(str);
ParsedISO8601Duration expected =
*TemporalParser::ParseTemporalDurationString(i_isolate(), input);
base::Optional<ParsedISO8601Duration> result =
TemporalParser::ParseTemporalDurationString(i_isolate(), input);
CHECK(result.has_value());
ParsedISO8601Duration expected = *result;
std::string with_sign("+");
with_sign += str;
VerifyParseDurationSuccess(with_sign.c_str(), expected);
......@@ -213,8 +227,10 @@ class TemporalParserTest : public TestWithIsolate {
std::string with_sign("-");
with_sign += str;
Handle<String> input = MakeString(with_sign.c_str());
ParsedISO8601Duration expected =
*TemporalParser::ParseTemporalDurationString(i_isolate(), input);
base::Optional<ParsedISO8601Duration> result =
TemporalParser::ParseTemporalDurationString(i_isolate(), input);
CHECK(result.has_value());
ParsedISO8601Duration expected = *result;
with_sign = "\u2212";
with_sign += str;
VerifyParseDurationSuccess(with_sign.c_str(), expected);
......@@ -222,8 +238,10 @@ class TemporalParserTest : public TestWithIsolate {
void VerifyParseDurationWithLowerCase(const char* str) {
Handle<String> input = MakeString(str);
ParsedISO8601Duration expected =
*TemporalParser::ParseTemporalDurationString(i_isolate(), input);
base::Optional<ParsedISO8601Duration> result =
TemporalParser::ParseTemporalDurationString(i_isolate(), input);
CHECK(result.has_value());
ParsedISO8601Duration expected = *result;
std::string lower(str);
std::transform(lower.begin(), lower.end(), lower.begin(), asciitolower);
VerifyParseDurationSuccess(lower.c_str(), expected);
......@@ -233,8 +251,10 @@ class TemporalParserTest : public TestWithIsolate {
std::string period(str);
std::transform(period.begin(), period.end(), period.begin(), commatoperiod);
Handle<String> input = MakeString(str);
ParsedISO8601Duration expected =
*TemporalParser::ParseTemporalDurationString(i_isolate(), input);
base::Optional<ParsedISO8601Duration> result =
TemporalParser::ParseTemporalDurationString(i_isolate(), input);
CHECK(result.has_value());
ParsedISO8601Duration expected = *result;
VerifyParseDurationSuccess(str, expected);
}
......@@ -242,9 +262,11 @@ class TemporalParserTest : public TestWithIsolate {
const char* str, int32_t tzuo_sign, int32_t tzuo_hour,
int32_t tzuo_minute, int32_t tzuo_second, int32_t tzuo_nanosecond) {
Handle<String> input = MakeString(str);
CheckTimeZoneNumericUTCOffset(
*TemporalParser::ParseTimeZoneNumericUTCOffset(i_isolate(), input),
tzuo_sign, tzuo_hour, tzuo_minute, tzuo_second, tzuo_nanosecond);
base::Optional<ParsedISO8601Result> result =
TemporalParser::ParseTimeZoneNumericUTCOffset(i_isolate(), input);
CHECK(result.has_value());
CheckTimeZoneNumericUTCOffset(*result, tzuo_sign, tzuo_hour, tzuo_minute,
tzuo_second, tzuo_nanosecond);
}
};
......@@ -375,9 +397,10 @@ class TemporalParserTest : public TestWithIsolate {
/* Out of range */ \
VERIFY_PARSE_FAIL(R, "1900-12-31[Etc/GMT+24]"); \
VERIFY_PARSE_FAIL(R, "1900-12-31[Etc/GMT-24]"); \
/* Single digit Hour */ \
VERIFY_PARSE_FAIL(R, "1900-12-31[Etc/GMT+2]"); \
VERIFY_PARSE_FAIL(R, "1900-12-31[Etc/GMT-0]"); \
/* leading 0 Hour */ \
VERIFY_PARSE_FAIL(R, "1900-12-31[Etc/GMT+02]"); \
VERIFY_PARSE_FAIL(R, "1900-12-31[Etc/GMT-00]"); \
VERIFY_PARSE_FAIL(R, "2021-11-09Z[Etc/GMT+01]"); \
/* Three digit hour */ \
VERIFY_PARSE_FAIL(R, "1900-12-31[Etc/GMT+201]"); \
VERIFY_PARSE_FAIL(R, "1900-12-31[Etc/GMT-000]"); \
......@@ -423,29 +446,6 @@ class TemporalParserTest : public TestWithIsolate {
} while (false)
TEST_F(TemporalParserTest, TemporalTimeStringSuccess) {
// DateTime
// DateYear - DateMonth - DateDay
VerifyTemporalTimeStringTimeUndefined("2021-11-03");
// DateYear DateMonth DateDay
VerifyTemporalTimeStringTimeUndefined("20211103");
// DateExtendedYear
VerifyTemporalTimeStringTimeUndefined("+002021-11-03");
VerifyTemporalTimeStringTimeUndefined("+000001-11-03");
VerifyTemporalTimeStringTimeUndefined("+0020211103");
VerifyTemporalTimeStringTimeUndefined("+0000011231");
VerifyTemporalTimeStringTimeUndefined("+0000000101");
VerifyTemporalTimeStringTimeUndefined("+0000000101");
VerifyTemporalTimeStringTimeUndefined("+654321-11-03");
VerifyTemporalTimeStringTimeUndefined("+999999-12-31");
VerifyTemporalTimeStringTimeUndefined("-654321-11-03");
VerifyTemporalTimeStringTimeUndefined("-999999-12-31");
VerifyTemporalTimeStringTimeUndefined("\u2212999999-12-31");
VerifyTemporalTimeStringTimeUndefined("+6543211103");
VerifyTemporalTimeStringTimeUndefined("+9999991231");
VerifyTemporalTimeStringTimeUndefined("-6543211103");
VerifyTemporalTimeStringTimeUndefined("-9999991231");
VerifyTemporalTimeStringTimeUndefined("\u22129999991231");
// DateTime: Date TimeSpecSeparator_opt TimeZone_opt
// Date TimeSpecSeparator
// Differeent DateTimeSeparator: <S> T or t
......@@ -475,17 +475,7 @@ TEST_F(TemporalParserTest, TemporalTimeStringSuccess) {
123456789, "");
VerifyParseTemporalTimeStringSuccess("19640710 09:18:27,12345678", 9, 18, 27,
123456780, "");
// Date TimeZone
// Date TimeZoneOffsetRequired
// Date TimeZoneUTCOffset TimeZoneBracketedAnnotation_opt
// Date TimeZoneNumericUTCOffset
VerifyTemporalTimeStringTimeUndefined("2021-11-09+11");
VerifyTemporalTimeStringTimeUndefined("2021-11-09-12:03");
VerifyTemporalTimeStringTimeUndefined("2021-11-09-1203");
VerifyTemporalTimeStringTimeUndefined("2021-11-09-12:03:04");
VerifyTemporalTimeStringTimeUndefined("2021-11-09-120304");
VerifyTemporalTimeStringTimeUndefined("2021-11-09-12:03:04,987654321");
VerifyTemporalTimeStringTimeUndefined("2021-11-09-120304.987654321");
VerifyParseTemporalTimeStringSuccess("2021-11-09T03+11", 3, kUndefined,
kUndefined, kUndefined, "");
VerifyParseTemporalTimeStringSuccess("2021-11-09t04:55-12:03", 4, 55,
......@@ -512,10 +502,7 @@ TEST_F(TemporalParserTest, TemporalTimeStringSuccess) {
"");
VerifyParseTemporalTimeStringSuccess(
"19670316T223344.987654321-120304.123456789", 22, 33, 44, 987654321, "");
// Date UTCDesignator
// Date UTCDesignator
VerifyTemporalTimeStringTimeUndefined("2021-11-09z");
VerifyTemporalTimeStringTimeUndefined("2021-11-09Z");
VerifyParseTemporalTimeStringSuccess("2021-11-09T11z", 11, kUndefined,
kUndefined, kUndefined, "");
VerifyParseTemporalTimeStringSuccess("2021-11-09t12Z", 12, kUndefined,
......@@ -538,24 +525,10 @@ TEST_F(TemporalParserTest, TemporalTimeStringSuccess) {
891234000, "");
VerifyParseTemporalTimeStringSuccess("20211109T012345,891234567Z", 1, 23, 45,
891234567, "");
// Date TimeZoneNameRequired
// Date TimeZoneBracketedAnnotation
VerifyTemporalTimeStringTimeUndefined("2021-11-09[Etc/GMT+01]");
VerifyTemporalTimeStringTimeUndefined("2021-11-09[Etc/GMT-23]");
VerifyTemporalTimeStringTimeUndefined("2021-11-09[Etc/GMT+23]");
VerifyTemporalTimeStringTimeUndefined("2021-11-09[Etc/GMT-00]");
VerifyTemporalTimeStringTimeUndefined("2021-11-09[Etc/GMT+01]");
VerifyTemporalTimeStringTimeUndefined("2021-11-09[Etc/GMT-23]");
VerifyParseTemporalTimeStringSuccess(
"2021-11-09 23:45:56.891234567Z[Etc/GMT+23]", 23, 45, 56, 891234567, "");
// TimeZoneIANAName
VerifyTemporalTimeStringTimeUndefined("2021-11-09[ABCDEFGHIJKLMN]");
VerifyTemporalTimeStringTimeUndefined(
"2021-11-09[ABCDEFGHIJKLMN/abcdefghijklmn/opeqrstuv]");
VerifyTemporalTimeStringTimeUndefined(
"2021-11-09[aBcDEfGHiJ.L_N/ABC...G_..KLMN]");
VerifyTemporalTimeStringTimeUndefined(
"2021-11-09[aBcDE-GHiJ.L_N/ABCbcdG-IJKLMN]");
VerifyParseTemporalTimeStringSuccess("2021-11-09T12z[.BCDEFGHIJKLMN]", 12,
kUndefined, kUndefined, kUndefined, "");
VerifyParseTemporalTimeStringSuccess(
......@@ -568,26 +541,10 @@ TEST_F(TemporalParserTest, TemporalTimeStringSuccess) {
"2021-11-09 "
"123456.789123456-012345.789123456[aBcDEfGHiJ.L_N/ABCbcdGfIJKLMN]",
12, 34, 56, 789123456, "");
// TimeZoneUTCOffsetName
VerifyTemporalTimeStringTimeUndefined("2021-11-09[+12]");
VerifyTemporalTimeStringTimeUndefined("2021-11-09[+12:34]");
VerifyTemporalTimeStringTimeUndefined("2021-11-09[+12:34:56]");
VerifyTemporalTimeStringTimeUndefined("2021-11-09[+12:34:56,789123456]");
VerifyTemporalTimeStringTimeUndefined("2021-11-09[+12:34:56.789123456]");
VerifyTemporalTimeStringTimeUndefined("2021-11-09[\u221200:34:56.789123456]");
VerifyParseTemporalTimeStringSuccess("2021-11-09 01:23:45.678912345Z", 1, 23,
45, 678912345, "");
VerifyParseTemporalTimeStringSuccess("2021-03-11[u-ca=iso8601]", kUndefined,
kUndefined, kUndefined, kUndefined,
"iso8601");
VerifyParseTemporalTimeStringSuccess("2021-03-11[u-ca=abcdefgh-wxyzefg]",
kUndefined, kUndefined, kUndefined,
kUndefined, "abcdefgh-wxyzefg");
VerifyParseTemporalTimeStringSuccess(
"2021-03-11[u-ca=abcdefgh-wxyzefg-ijklmnop]", kUndefined, kUndefined,
kUndefined, kUndefined, "abcdefgh-wxyzefg-ijklmnop");
VerifyParseTemporalTimeStringSuccess("2021-03-11T01[u-ca=iso8601]", 1,
kUndefined, kUndefined, kUndefined,
"iso8601");
......@@ -601,34 +558,18 @@ TEST_F(TemporalParserTest, TemporalTimeStringSuccess) {
"ABCbcdGfIJKLMN][u-ca=abc]",
12, 34, 56, 789000000, "abc");
VerifyParseTemporalTimeStringSuccess(
"2021-03-11[+12:34:56,789123456][u-ca=abcdefgh-wxyzefg]", kUndefined,
kUndefined, kUndefined, kUndefined, "abcdefgh-wxyzefg");
VerifyParseTemporalTimeStringSuccess(
"2021-03-11T23[+12:34:56,789123456][u-ca=abcdefgh-wxyzefg]", 23,
kUndefined, kUndefined, kUndefined, "abcdefgh-wxyzefg");
VerifyParseTemporalTimeStringSuccess(
"20210311[\u221200:34:56.789123456][u-ca=abcdefgh-wxyzefg-ijklmnop]",
kUndefined, kUndefined, kUndefined, kUndefined,
"abcdefgh-wxyzefg-ijklmnop");
VerifyParseTemporalTimeStringSuccess(
"20210311T22:11[\u221200:34:56.789123456][u-ca=abcdefgh-"
"wxyzefg-ijklmnop]",
22, 11, kUndefined, kUndefined, "abcdefgh-wxyzefg-ijklmnop");
VerifyParseTemporalTimeStringSuccess("2021-11-03[u-ca=abc]", kUndefined,
kUndefined, kUndefined, kUndefined,
"abc");
VerifyParseTemporalTimeStringSuccess("2021-11-03T23:45:12.345[u-ca=abc]", 23,
45, 12, 345000000, "abc");
VerifyParseTemporalTimeStringSuccess("2021-11-03[u-ca=iso-8601]", kUndefined,
kUndefined, kUndefined, kUndefined,
"iso-8601");
VerifyParseTemporalTimeStringSuccess("2021-11-03 234527[u-ca=iso-8601]", 23,
45, 27, kUndefined, "iso-8601");
VerifyParseTemporalTimeStringSuccess("2021-11-03[u-ca=123456-789]",
kUndefined, kUndefined, kUndefined,
kUndefined, "123456-789");
VerifyParseTemporalTimeStringSuccess("2021-11-03t12[u-ca=123456-789]", 12,
kUndefined, kUndefined, kUndefined,
"123456-789");
......@@ -681,6 +622,80 @@ TEST_F(TemporalParserTest, TemporalTimeStringIllegal) {
VERIFY_PARSE_FAIL(TemporalTimeString, "23:60:02.123456789");
VERIFY_PARSE_FAIL(TemporalTimeString, "23:59:61.123456789");
VERIFY_PARSE_FAIL(TemporalTimeString, "23:33:44.0000000000");
VERIFY_PARSE_FAIL(TemporalTimeString, "1900-12-31[Etc/GMT+2]");
VERIFY_PARSE_FAIL(TemporalTimeString, "1900-12-31[Etc/GMT-0]");
VERIFY_PARSE_FAIL(TemporalTimeString, "1900-12-31[Etc/GMT-0]");
// Date TimeZone
// DateExtendedYear
VERIFY_PARSE_FAIL(TemporalTimeString, "+002021-11-03");
VERIFY_PARSE_FAIL(TemporalTimeString, "+000001-11-03");
VERIFY_PARSE_FAIL(TemporalTimeString, "+0020211103");
VERIFY_PARSE_FAIL(TemporalTimeString, "+0000011231");
VERIFY_PARSE_FAIL(TemporalTimeString, "+0000000101");
VERIFY_PARSE_FAIL(TemporalTimeString, "+0000000101");
VERIFY_PARSE_FAIL(TemporalTimeString, "+654321-11-03");
VERIFY_PARSE_FAIL(TemporalTimeString, "+999999-12-31");
VERIFY_PARSE_FAIL(TemporalTimeString, "-654321-11-03");
VERIFY_PARSE_FAIL(TemporalTimeString, "-999999-12-31");
VERIFY_PARSE_FAIL(TemporalTimeString, "\u2212999999-12-31");
VERIFY_PARSE_FAIL(TemporalTimeString, "+6543211103");
VERIFY_PARSE_FAIL(TemporalTimeString, "+9999991231");
VERIFY_PARSE_FAIL(TemporalTimeString, "-6543211103");
VERIFY_PARSE_FAIL(TemporalTimeString, "-9999991231");
VERIFY_PARSE_FAIL(TemporalTimeString, "\u22129999991231");
// Date TimeZone
// Date TimeZoneOffsetRequired
// Date TimeZoneUTCOffset TimeZoneBracketedAnnotation_opt
// Date TimeZoneNumericUTCOffset
VERIFY_PARSE_FAIL(TemporalTimeString, "2021-11-09+11");
VERIFY_PARSE_FAIL(TemporalTimeString, "2021-11-09-12:03");
VERIFY_PARSE_FAIL(TemporalTimeString, "2021-11-09-1203");
VERIFY_PARSE_FAIL(TemporalTimeString, "2021-11-09-12:03:04");
VERIFY_PARSE_FAIL(TemporalTimeString, "2021-11-09-120304");
VERIFY_PARSE_FAIL(TemporalTimeString, "2021-11-09-12:03:04,987654321");
VERIFY_PARSE_FAIL(TemporalTimeString, "2021-11-09-120304.987654321");
// Date UTCDesignator
// Date UTCDesignator
VERIFY_PARSE_FAIL(TemporalTimeString, "2021-11-09z");
VERIFY_PARSE_FAIL(TemporalTimeString, "2021-11-09Z");
// Date TimeZoneNameRequired
// Date TimeZoneBracketedAnnotation
VERIFY_PARSE_FAIL(TemporalTimeString, "2021-11-09[Etc/GMT+01]");
VERIFY_PARSE_FAIL(TemporalTimeString, "2021-11-09[Etc/GMT-23]");
VERIFY_PARSE_FAIL(TemporalTimeString, "2021-11-09[Etc/GMT+23]");
VERIFY_PARSE_FAIL(TemporalTimeString, "2021-11-09[Etc/GMT-00]");
VERIFY_PARSE_FAIL(TemporalTimeString, "2021-11-09[Etc/GMT+01]");
VERIFY_PARSE_FAIL(TemporalTimeString, "2021-11-09[Etc/GMT-23]");
VERIFY_PARSE_FAIL(TemporalTimeString, "2021-11-09[ABCDEFGHIJKLMN]");
VERIFY_PARSE_FAIL(TemporalTimeString,
"2021-11-09[ABCDEFGHIJKLMN/abcdefghijklmn/opeqrstuv]");
VERIFY_PARSE_FAIL(TemporalTimeString,
"2021-11-09[aBcDEfGHiJ.L_N/ABC...G_..KLMN]");
VERIFY_PARSE_FAIL(TemporalTimeString,
"2021-11-09[aBcDE-GHiJ.L_N/ABCbcdG-IJKLMN]");
// TimeZoneUTCOffsetName
VERIFY_PARSE_FAIL(TemporalTimeString, "2021-11-09[+12]");
VERIFY_PARSE_FAIL(TemporalTimeString, "2021-11-09[+12:34]");
VERIFY_PARSE_FAIL(TemporalTimeString, "2021-11-09[+12:34:56]");
VERIFY_PARSE_FAIL(TemporalTimeString, "2021-11-09[+12:34:56,789123456]");
VERIFY_PARSE_FAIL(TemporalTimeString, "2021-11-09[+12:34:56.789123456]");
VERIFY_PARSE_FAIL(TemporalTimeString, "2021-11-09[\u221200:34:56.789123456]");
VERIFY_PARSE_FAIL(TemporalTimeString, "2021-03-11[u-ca=iso8601]");
VERIFY_PARSE_FAIL(TemporalTimeString, "2021-03-11[u-ca=abcdefgh-wxyzefg]");
VERIFY_PARSE_FAIL(TemporalTimeString,
"2021-03-11[u-ca=abcdefgh-wxyzefg-ijklmnop]");
VERIFY_PARSE_FAIL(TemporalTimeString,
"2021-03-11[+12:34:56,789123456][u-ca=abcdefgh-wxyzefg]");
VERIFY_PARSE_FAIL(TemporalTimeString, "2021-11-03[u-ca=abc]");
VERIFY_PARSE_FAIL(TemporalTimeString, "2021-11-03[u-ca=iso-8601]");
VERIFY_PARSE_FAIL(TemporalTimeString, "2021-11-03[u-ca=123456-789]");
}
#define IMPL_DATE_TIME_STRING_SUCCESS(R) \
......@@ -828,17 +843,16 @@ TEST_F(TemporalParserTest, TemporalTimeStringIllegal) {
45, 891234567, ""); \
/* Date TimeZoneNameRequired */ \
/* Date TimeZoneBracketedAnnotation */ \
VerifyParse##R##Success("2021-11-09[Etc/GMT+01]", 2021, 11, 9, kUndefined, \
VerifyParse##R##Success("2021-11-09[Etc/GMT+1]", 2021, 11, 9, kUndefined, \
kUndefined, kUndefined, kUndefined, ""); \
VerifyParse##R##Success("2021-11-09[Etc/GMT-23]", 2021, 11, 9, kUndefined, \
kUndefined, kUndefined, kUndefined, ""); \
VerifyParse##R##Success("2021-11-09[Etc/GMT+23]", 2021, 11, 9, kUndefined, \
kUndefined, kUndefined, kUndefined, ""); \
VerifyParse##R##Success("2021-11-09[Etc/GMT-00]", 2021, 11, 9, kUndefined, \
VerifyParse##R##Success("2021-11-09[Etc/GMT-0]", 2021, 11, 9, kUndefined, \
kUndefined, kUndefined, kUndefined, ""); \
VerifyParse##R##Success("2021-11-09Z[Etc/GMT+1]", 2021, 11, 9, kUndefined, \
kUndefined, kUndefined, kUndefined, ""); \
VerifyParse##R##Success("2021-11-09Z[Etc/GMT+01]", 2021, 11, 9, \
kUndefined, kUndefined, kUndefined, kUndefined, \
""); \
VerifyParse##R##Success("2021-11-09z[Etc/GMT-23]", 2021, 11, 9, \
kUndefined, kUndefined, kUndefined, kUndefined, \
""); \
......@@ -1072,15 +1086,15 @@ TEST_F(TemporalParserTest, TemporalYearMonthStringSuccess) {
11, 9, "");
// Date TimeZoneNameRequired
// Date TimeZoneBracketedAnnotation
VerifyParseTemporalYearMonthStringSuccess("2021-11-09[Etc/GMT+01]", 2021, 11,
VerifyParseTemporalYearMonthStringSuccess("2021-11-09[Etc/GMT+1]", 2021, 11,
9, "");
VerifyParseTemporalYearMonthStringSuccess("2021-11-09[Etc/GMT-23]", 2021, 11,
9, "");
VerifyParseTemporalYearMonthStringSuccess("2021-11-09[Etc/GMT+23]", 2021, 11,
9, "");
VerifyParseTemporalYearMonthStringSuccess("2021-11-09[Etc/GMT-00]", 2021, 11,
VerifyParseTemporalYearMonthStringSuccess("2021-11-09[Etc/GMT-0]", 2021, 11,
9, "");
VerifyParseTemporalYearMonthStringSuccess("2021-11-09Z[Etc/GMT+01]", 2021, 11,
VerifyParseTemporalYearMonthStringSuccess("2021-11-09Z[Etc/GMT+1]", 2021, 11,
9, "");
VerifyParseTemporalYearMonthStringSuccess("2021-11-09z[Etc/GMT-23]", 2021, 11,
9, "");
......@@ -1298,15 +1312,15 @@ TEST_F(TemporalParserTest, TemporalMonthDayStringSuccess) {
11, 9, "");
// Date TimeZoneNameRequired
// Date TimeZoneBracketedAnnotation
VerifyParseTemporalMonthDayStringSuccess("2021-11-09[Etc/GMT+01]", 2021, 11,
9, "");
VerifyParseTemporalMonthDayStringSuccess("2021-11-09[Etc/GMT+1]", 2021, 11, 9,
"");
VerifyParseTemporalMonthDayStringSuccess("2021-11-09[Etc/GMT-23]", 2021, 11,
9, "");
VerifyParseTemporalMonthDayStringSuccess("2021-11-09[Etc/GMT+23]", 2021, 11,
9, "");
VerifyParseTemporalMonthDayStringSuccess("2021-11-09[Etc/GMT-00]", 2021, 11,
9, "");
VerifyParseTemporalMonthDayStringSuccess("2021-11-09Z[Etc/GMT+01]", 2021, 11,
VerifyParseTemporalMonthDayStringSuccess("2021-11-09[Etc/GMT-0]", 2021, 11, 9,
"");
VerifyParseTemporalMonthDayStringSuccess("2021-11-09Z[Etc/GMT+1]", 2021, 11,
9, "");
VerifyParseTemporalMonthDayStringSuccess("2021-11-09z[Etc/GMT-23]", 2021, 11,
9, "");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment