summaryrefslogtreecommitdiffstats
path: root/js/src/builtin/temporal/TemporalParser.cpp
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--js/src/builtin/temporal/TemporalParser.cpp284
1 files changed, 140 insertions, 144 deletions
diff --git a/js/src/builtin/temporal/TemporalParser.cpp b/js/src/builtin/temporal/TemporalParser.cpp
index c117e63b31..b3a7a58c62 100644
--- a/js/src/builtin/temporal/TemporalParser.cpp
+++ b/js/src/builtin/temporal/TemporalParser.cpp
@@ -80,11 +80,11 @@ bool EqualCharIgnoreCaseAscii(CharT c1, char c2) {
// Convert both characters to lower case before the comparison.
char c = c1;
if (mozilla::IsAsciiUppercaseAlpha(c1)) {
- c = c + toLower;
+ c = char(c + toLower);
}
char d = c2;
if (mozilla::IsAsciiUppercaseAlpha(c2)) {
- d = d + toLower;
+ d = char(d + toLower);
}
return c == d;
}
@@ -544,10 +544,10 @@ class TemporalParser final {
return mozilla::Some(num);
}
- // TimeFractionalPart :
+ // TimeFractionalPart :::
// Digit{1, 9}
//
- // Fraction :
+ // Fraction :::
// DecimalSeparator TimeFractionalPart
mozilla::Maybe<int32_t> fraction() {
if (!reader_.hasMore(2)) {
@@ -679,11 +679,11 @@ class TemporalParser final {
return true;
}
- // Sign :
+ // Sign :::
// ASCIISign
// U+2212
//
- // ASCIISign : one of
+ // ASCIISign ::: one of
// + -
bool hasSign() const { return hasOneOf({'+', '-', 0x2212}); }
@@ -698,61 +698,61 @@ class TemporalParser final {
return plus ? 1 : -1;
}
- // DecimalSeparator : one of
+ // DecimalSeparator ::: one of
// . ,
bool hasDecimalSeparator() const { return hasOneOf({'.', ','}); }
bool decimalSeparator() { return oneOf({'.', ','}); }
- // DaysDesignator : one of
+ // DaysDesignator ::: one of
// D d
bool daysDesignator() { return oneOf({'D', 'd'}); }
- // HoursDesignator : one of
+ // HoursDesignator ::: one of
// H h
bool hoursDesignator() { return oneOf({'H', 'h'}); }
- // MinutesDesignator : one of
+ // MinutesDesignator ::: one of
// M m
bool minutesDesignator() { return oneOf({'M', 'm'}); }
- // MonthsDesignator : one of
+ // MonthsDesignator ::: one of
// M m
bool monthsDesignator() { return oneOf({'M', 'm'}); }
- // DurationDesignator : one of
+ // DurationDesignator ::: one of
// P p
bool durationDesignator() { return oneOf({'P', 'p'}); }
- // SecondsDesignator : one of
+ // SecondsDesignator ::: one of
// S s
bool secondsDesignator() { return oneOf({'S', 's'}); }
- // DateTimeSeparator :
+ // DateTimeSeparator :::
// <SP>
// T
// t
bool dateTimeSeparator() { return oneOf({' ', 'T', 't'}); }
- // TimeDesignator : one of
+ // TimeDesignator ::: one of
// T t
bool hasTimeDesignator() const { return hasOneOf({'T', 't'}); }
bool timeDesignator() { return oneOf({'T', 't'}); }
- // WeeksDesignator : one of
+ // WeeksDesignator ::: one of
// W w
bool weeksDesignator() { return oneOf({'W', 'w'}); }
- // YearsDesignator : one of
+ // YearsDesignator ::: one of
// Y y
bool yearsDesignator() { return oneOf({'Y', 'y'}); }
- // UTCDesignator : one of
+ // UTCDesignator ::: one of
// Z z
bool utcDesignator() { return oneOf({'Z', 'z'}); }
- // TZLeadingChar :
+ // TZLeadingChar :::
// Alpha
// .
// _
@@ -762,7 +762,7 @@ class TemporalParser final {
});
}
- // TZChar :
+ // TZChar :::
// TZLeadingChar
// DecimalDigit
// -
@@ -774,11 +774,11 @@ class TemporalParser final {
});
}
- // AnnotationCriticalFlag :
+ // AnnotationCriticalFlag :::
// !
bool annotationCriticalFlag() { return character('!'); }
- // AKeyLeadingChar :
+ // AKeyLeadingChar :::
// LowercaseAlpha
// _
bool aKeyLeadingChar() {
@@ -787,7 +787,7 @@ class TemporalParser final {
});
}
- // AKeyChar :
+ // AKeyChar :::
// AKeyLeadingChar
// DecimalDigit
// -
@@ -798,7 +798,7 @@ class TemporalParser final {
});
}
- // AnnotationValueComponent :
+ // AnnotationValueComponent :::
// Alpha AnnotationValueComponent?
// DecimalDigit AnnotationValueComponent?
bool annotationValueComponent() {
@@ -929,7 +929,7 @@ class TemporalParser final {
template <typename CharT>
mozilla::Result<ZonedDateTimeString, ParserError>
TemporalParser<CharT>::dateTime() {
- // DateTime :
+ // DateTime :::
// Date
// Date DateTimeSeparator TimeSpec DateTimeUTCOffset?
ZonedDateTimeString result = {};
@@ -961,12 +961,12 @@ TemporalParser<CharT>::dateTime() {
template <typename CharT>
mozilla::Result<PlainDate, ParserError> TemporalParser<CharT>::date() {
- // Date :
+ // Date :::
// DateYear - DateMonth - DateDay
// DateYear DateMonth DateDay
PlainDate result = {};
- // DateYear :
+ // DateYear :::
// DecimalDigit{4}
// Sign DecimalDigit{6}
if (auto year = digits(4)) {
@@ -988,7 +988,7 @@ mozilla::Result<PlainDate, ParserError> TemporalParser<CharT>::date() {
// Optional: -
character('-');
- // DateMonth :
+ // DateMonth :::
// 0 NonzeroDigit
// 10
// 11
@@ -1005,7 +1005,7 @@ mozilla::Result<PlainDate, ParserError> TemporalParser<CharT>::date() {
// Optional: -
character('-');
- // DateDay :
+ // DateDay :::
// 0 NonzeroDigit
// 1 DecimalDigit
// 2 DecimalDigit
@@ -1025,7 +1025,7 @@ mozilla::Result<PlainDate, ParserError> TemporalParser<CharT>::date() {
template <typename CharT>
mozilla::Result<PlainTime, ParserError> TemporalParser<CharT>::timeSpec() {
- // TimeSpec :
+ // TimeSpec :::
// TimeHour
// TimeHour : TimeMinute
// TimeHour TimeMinute
@@ -1033,12 +1033,11 @@ mozilla::Result<PlainTime, ParserError> TemporalParser<CharT>::timeSpec() {
// TimeHour TimeMinute TimeSecond TimeFraction?
PlainTime result = {};
- // TimeHour :
- // Hour[+Padded]
+ // TimeHour :::
+ // Hour
//
- // Hour[Padded] :
- // [~Padded] DecimalDigit
- // [~Padded] 0 DecimalDigit
+ // Hour :::
+ // 0 DecimalDigit
// 1 DecimalDigit
// 20
// 21
@@ -1056,10 +1055,10 @@ mozilla::Result<PlainTime, ParserError> TemporalParser<CharT>::timeSpec() {
// Optional: :
bool needsMinutes = character(':');
- // TimeMinute :
+ // TimeMinute :::
// MinuteSecond
//
- // MinuteSecond :
+ // MinuteSecond :::
// 0 DecimalDigit
// 1 DecimalDigit
// 2 DecimalDigit
@@ -1075,7 +1074,7 @@ mozilla::Result<PlainTime, ParserError> TemporalParser<CharT>::timeSpec() {
// Optional: :
bool needsSeconds = needsMinutes && character(':');
- // TimeSecond :
+ // TimeSecond :::
// MinuteSecond
// 60
if (auto second = digits(2)) {
@@ -1084,7 +1083,7 @@ mozilla::Result<PlainTime, ParserError> TemporalParser<CharT>::timeSpec() {
return mozilla::Err(JSMSG_TEMPORAL_PARSER_INVALID_LEAPSECOND);
}
- // TimeFraction :
+ // TimeFraction :::
// Fraction
if (auto f = fraction()) {
int32_t fractionalPart = f.value();
@@ -1105,7 +1104,7 @@ mozilla::Result<PlainTime, ParserError> TemporalParser<CharT>::timeSpec() {
template <typename CharT>
mozilla::Result<TimeZoneString, ParserError>
TemporalParser<CharT>::dateTimeUTCOffset() {
- // DateTimeUTCOffset :
+ // DateTimeUTCOffset :::
// UTCDesignator
// UTCOffsetSubMinutePrecision
@@ -1127,13 +1126,13 @@ TemporalParser<CharT>::dateTimeUTCOffset() {
template <typename CharT>
mozilla::Result<TimeZoneUTCOffset, ParserError>
TemporalParser<CharT>::timeZoneUTCOffsetName() {
- // TimeZoneUTCOffsetName :
+ // TimeZoneUTCOffsetName :::
// UTCOffsetMinutePrecision
//
- // UTCOffsetMinutePrecision :
- // Sign Hour[+Padded]
- // Sign Hour[+Padded] TimeSeparator[+Extended] MinuteSecond
- // Sign Hour[+Padded] TimeSeparator[~Extended] MinuteSecond
+ // UTCOffsetMinutePrecision :::
+ // Sign Hour
+ // Sign Hour TimeSeparator[+Extended] MinuteSecond
+ // Sign Hour TimeSeparator[~Extended] MinuteSecond
TimeZoneUTCOffset result = {};
@@ -1142,9 +1141,8 @@ TemporalParser<CharT>::timeZoneUTCOffsetName() {
}
result.sign = sign();
- // Hour[Padded] :
- // [~Padded] DecimalDigit
- // [+Padded] 0 DecimalDigit
+ // Hour :::
+ // 0 DecimalDigit
// 1 DecimalDigit
// 20
// 21
@@ -1159,12 +1157,12 @@ TemporalParser<CharT>::timeZoneUTCOffsetName() {
return mozilla::Err(JSMSG_TEMPORAL_PARSER_MISSING_HOUR);
}
- // TimeSeparator[Extended] :
+ // TimeSeparator[Extended] :::
// [+Extended] :
// [~Extended] [empty]
bool needsMinutes = character(':');
- // MinuteSecond :
+ // MinuteSecond :::
// 0 DecimalDigit
// 1 DecimalDigit
// 2 DecimalDigit
@@ -1192,18 +1190,18 @@ mozilla::Result<DateTimeUTCOffset, ParserError>
TemporalParser<CharT>::utcOffsetSubMinutePrecision() {
// clang-format off
//
- // UTCOffsetSubMinutePrecision :
+ // UTCOffsetSubMinutePrecision :::
// UTCOffsetMinutePrecision
// UTCOffsetWithSubMinuteComponents[+Extended]
// UTCOffsetWithSubMinuteComponents[~Extended]
//
- // UTCOffsetMinutePrecision :
- // Sign Hour[+Padded]
- // Sign Hour[+Padded] TimeSeparator[+Extended] MinuteSecond
- // Sign Hour[+Padded] TimeSeparator[~Extended] MinuteSecond
+ // UTCOffsetMinutePrecision :::
+ // Sign Hour
+ // Sign Hour TimeSeparator[+Extended] MinuteSecond
+ // Sign Hour TimeSeparator[~Extended] MinuteSecond
//
- // UTCOffsetWithSubMinuteComponents[Extended] :
- // Sign Hour[+Padded] TimeSeparator[?Extended] MinuteSecond TimeSeparator[?Extended] MinuteSecond Fraction?
+ // UTCOffsetWithSubMinuteComponents[Extended] :::
+ // Sign Hour TimeSeparator[?Extended] MinuteSecond TimeSeparator[?Extended] MinuteSecond Fraction?
//
// clang-format on
@@ -1214,9 +1212,8 @@ TemporalParser<CharT>::utcOffsetSubMinutePrecision() {
}
result.sign = sign();
- // Hour[Padded] :
- // [~Padded] DecimalDigit
- // [+Padded] 0 DecimalDigit
+ // Hour :::
+ // 0 DecimalDigit
// 1 DecimalDigit
// 20
// 21
@@ -1231,12 +1228,12 @@ TemporalParser<CharT>::utcOffsetSubMinutePrecision() {
return mozilla::Err(JSMSG_TEMPORAL_PARSER_MISSING_HOUR);
}
- // TimeSeparator[Extended] :
+ // TimeSeparator[Extended] :::
// [+Extended] :
// [~Extended] [empty]
bool needsMinutes = character(':');
- // MinuteSecond :
+ // MinuteSecond :::
// 0 DecimalDigit
// 1 DecimalDigit
// 2 DecimalDigit
@@ -1249,12 +1246,12 @@ TemporalParser<CharT>::utcOffsetSubMinutePrecision() {
return mozilla::Err(JSMSG_TEMPORAL_PARSER_INVALID_MINUTE);
}
- // TimeSeparator[Extended] :
+ // TimeSeparator[Extended] :::
// [+Extended] :
// [~Extended] [empty]
bool needsSeconds = needsMinutes && character(':');
- // MinuteSecond :
+ // MinuteSecond :::
// 0 DecimalDigit
// 1 DecimalDigit
// 2 DecimalDigit
@@ -1285,7 +1282,7 @@ TemporalParser<CharT>::utcOffsetSubMinutePrecision() {
template <typename CharT>
mozilla::Result<TimeZoneAnnotation, ParserError>
TemporalParser<CharT>::timeZoneIdentifier() {
- // TimeZoneIdentifier :
+ // TimeZoneIdentifier :::
// TimeZoneUTCOffsetName
// TimeZoneIANAName
@@ -1310,7 +1307,7 @@ TemporalParser<CharT>::timeZoneIdentifier() {
template <typename CharT>
mozilla::Result<TimeZoneAnnotation, ParserError>
TemporalParser<CharT>::timeZoneAnnotation() {
- // TimeZoneAnnotation :
+ // TimeZoneAnnotation :::
// [ AnnotationCriticalFlag? TimeZoneIdentifier ]
if (!character('[')) {
@@ -1335,11 +1332,11 @@ TemporalParser<CharT>::timeZoneAnnotation() {
template <typename CharT>
mozilla::Result<TimeZoneName, ParserError>
TemporalParser<CharT>::timeZoneIANAName() {
- // TimeZoneIANAName :
+ // TimeZoneIANAName :::
// TimeZoneIANANameComponent
// TimeZoneIANAName / TimeZoneIANANameComponent
//
- // TimeZoneIANANameComponent :
+ // TimeZoneIANANameComponent :::
// TZLeadingChar
// TimeZoneIANANameComponent TZChar
@@ -1385,7 +1382,7 @@ TemporalParser<CharT>::parseTemporalInstantString() {
// clang-format off
//
- // TemporalInstantString :
+ // TemporalInstantString :::
// Date DateTimeSeparator TimeSpec DateTimeUTCOffset TimeZoneAnnotation? Annotations?
//
// clang-format on
@@ -1492,7 +1489,7 @@ bool js::temporal::ParseTemporalInstantString(JSContext* cx,
template <typename CharT>
mozilla::Result<ZonedDateTimeString, ParserError>
TemporalParser<CharT>::parseTemporalTimeZoneString() {
- // TimeZoneIdentifier :
+ // TimeZoneIdentifier :::
// TimeZoneUTCOffsetName
// TimeZoneIANAName
@@ -1819,10 +1816,10 @@ TemporalParser<CharT>::parseTemporalDurationString(JSContext* cx) {
// Initialize all fields to zero.
TemporalDurationString result = {};
- // TemporalDurationString :
+ // TemporalDurationString :::
// Duration
//
- // Duration :
+ // Duration :::
// Sign? DurationDesignator DurationDate
// Sign? DurationDesignator DurationTime
@@ -1834,7 +1831,7 @@ TemporalParser<CharT>::parseTemporalDurationString(JSContext* cx) {
return mozilla::Err(JSMSG_TEMPORAL_PARSER_MISSING_DURATION_DESIGNATOR);
}
- // DurationDate :
+ // DurationDate :::
// DurationYearsPart DurationTime?
// DurationMonthsPart DurationTime?
// DurationWeeksPart DurationTime?
@@ -1851,12 +1848,12 @@ TemporalParser<CharT>::parseTemporalDurationString(JSContext* cx) {
num = *d;
}
- // DurationYearsPart :
+ // DurationYearsPart :::
// DurationYears YearsDesignator DurationMonthsPart
// DurationYears YearsDesignator DurationWeeksPart
// DurationYears YearsDesignator DurationDaysPart?
//
- // DurationYears :
+ // DurationYears :::
// DecimalDigits[~Sep]
if (yearsDesignator()) {
result.years = num;
@@ -1873,11 +1870,11 @@ TemporalParser<CharT>::parseTemporalDurationString(JSContext* cx) {
}
}
- // DurationMonthsPart :
+ // DurationMonthsPart :::
// DurationMonths MonthsDesignator DurationWeeksPart
// DurationMonths MonthsDesignator DurationDaysPart?
//
- // DurationMonths :
+ // DurationMonths :::
// DecimalDigits[~Sep]
if (monthsDesignator()) {
result.months = num;
@@ -1894,10 +1891,10 @@ TemporalParser<CharT>::parseTemporalDurationString(JSContext* cx) {
}
}
- // DurationWeeksPart :
+ // DurationWeeksPart :::
// DurationWeeks WeeksDesignator DurationDaysPart?
//
- // DurationWeeks :
+ // DurationWeeks :::
// DecimalDigits[~Sep]
if (weeksDesignator()) {
result.weeks = num;
@@ -1914,10 +1911,10 @@ TemporalParser<CharT>::parseTemporalDurationString(JSContext* cx) {
}
}
- // DurationDaysPart :
+ // DurationDaysPart :::
// DurationDays DaysDesignator
//
- // DurationDays :
+ // DurationDays :::
// DecimalDigits[~Sep]
if (daysDesignator()) {
result.days = num;
@@ -1932,7 +1929,7 @@ TemporalParser<CharT>::parseTemporalDurationString(JSContext* cx) {
return mozilla::Err(JSMSG_TEMPORAL_PARSER_GARBAGE_AFTER_INPUT);
} while (false);
- // DurationTime :
+ // DurationTime :::
// DurationTimeDesignator DurationHoursPart
// DurationTimeDesignator DurationMinutesPart
// DurationTimeDesignator DurationSecondsPart
@@ -1958,18 +1955,18 @@ TemporalParser<CharT>::parseTemporalDurationString(JSContext* cx) {
// clang-format off
//
- // DurationHoursPart :
+ // DurationHoursPart :::
// DurationWholeHours DurationHoursFraction HoursDesignator
// DurationWholeHours HoursDesignator DurationMinutesPart
// DurationWholeHours HoursDesignator DurationSecondsPart?
//
- // DurationWholeHours :
+ // DurationWholeHours :::
// DecimalDigits[~Sep]
//
- // DurationHoursFraction :
+ // DurationHoursFraction :::
// TimeFraction
//
- // TimeFraction :
+ // TimeFraction :::
// Fraction
//
// clang-format on
@@ -1988,17 +1985,17 @@ TemporalParser<CharT>::parseTemporalDurationString(JSContext* cx) {
// clang-format off
//
- // DurationMinutesPart :
+ // DurationMinutesPart :::
// DurationWholeMinutes DurationMinutesFraction MinutesDesignator
// DurationWholeMinutes MinutesDesignator DurationSecondsPart?
//
- // DurationWholeMinutes :
+ // DurationWholeMinutes :::
// DecimalDigits[~Sep]
//
- // DurationMinutesFraction :
+ // DurationMinutesFraction :::
// TimeFraction
//
- // TimeFraction :
+ // TimeFraction :::
// Fraction
//
// clang-format on
@@ -2018,16 +2015,16 @@ TemporalParser<CharT>::parseTemporalDurationString(JSContext* cx) {
}
}
- // DurationSecondsPart :
+ // DurationSecondsPart :::
// DurationWholeSeconds DurationSecondsFraction? SecondsDesignator
//
- // DurationWholeSeconds :
+ // DurationWholeSeconds :::
// DecimalDigits[~Sep]
//
- // DurationSecondsFraction :
+ // DurationSecondsFraction :::
// TimeFraction
//
- // TimeFraction :
+ // TimeFraction :::
// Fraction
if (secondsDesignator()) {
if (hasHoursFraction || hasMinutesFraction) {
@@ -2106,14 +2103,14 @@ bool js::temporal::ParseTemporalDurationString(JSContext* cx,
// Steps 9.b-d.
int64_t h = int64_t(parsed.hoursFraction) * 60;
- minutes = h / 1'000'000'000;
+ minutes = double(h / 1'000'000'000);
// Steps 13 and 15-17.
int64_t min = (h % 1'000'000'000) * 60;
- seconds = min / 1'000'000'000;
- milliseconds = (min % 1'000'000'000) / 1'000'000;
- microseconds = (min % 1'000'000) / 1'000;
- nanoseconds = (min % 1'000);
+ seconds = double(min / 1'000'000'000);
+ milliseconds = double((min % 1'000'000'000) / 1'000'000);
+ microseconds = double((min % 1'000'000) / 1'000);
+ nanoseconds = double(min % 1'000);
}
// Step 11.
@@ -2130,10 +2127,10 @@ bool js::temporal::ParseTemporalDurationString(JSContext* cx,
// Steps 11.b-d and 15-17.
int64_t min = int64_t(parsed.minutesFraction) * 60;
- seconds = min / 1'000'000'000;
- milliseconds = (min % 1'000'000'000) / 1'000'000;
- microseconds = (min % 1'000'000) / 1'000;
- nanoseconds = (min % 1'000);
+ seconds = double(min / 1'000'000'000);
+ milliseconds = double((min % 1'000'000'000) / 1'000'000);
+ microseconds = double((min % 1'000'000) / 1'000);
+ nanoseconds = double(min % 1'000);
}
// Step 14.
@@ -2148,9 +2145,9 @@ bool js::temporal::ParseTemporalDurationString(JSContext* cx,
seconds = parsed.seconds;
// Steps 14, 16-17
- milliseconds = (parsed.secondsFraction / 1'000'000);
- microseconds = ((parsed.secondsFraction % 1'000'000) / 1'000);
- nanoseconds = (parsed.secondsFraction % 1'000);
+ milliseconds = double(parsed.secondsFraction / 1'000'000);
+ microseconds = double((parsed.secondsFraction % 1'000'000) / 1'000);
+ nanoseconds = double(parsed.secondsFraction % 1'000);
} else {
// Step 10.
minutes = parsed.minutes;
@@ -2168,7 +2165,7 @@ bool js::temporal::ParseTemporalDurationString(JSContext* cx,
int32_t factor = parsed.sign ? parsed.sign : 1;
MOZ_ASSERT(factor == -1 || factor == 1);
- // Step 20.
+ // Steps 20-29.
*result = {
(years * factor) + (+0.0), (months * factor) + (+0.0),
(weeks * factor) + (+0.0), (days * factor) + (+0.0),
@@ -2176,16 +2173,15 @@ bool js::temporal::ParseTemporalDurationString(JSContext* cx,
(seconds * factor) + (+0.0), (milliseconds * factor) + (+0.0),
(microseconds * factor) + (+0.0), (nanoseconds * factor) + (+0.0),
};
- if (!ThrowIfInvalidDuration(cx, *result)) {
- return false;
- }
- return true;
+
+ // Steps 30-31.
+ return ThrowIfInvalidDuration(cx, *result);
}
template <typename CharT>
mozilla::Result<AnnotationKey, ParserError>
TemporalParser<CharT>::annotationKey() {
- // AnnotationKey :
+ // AnnotationKey :::
// AKeyLeadingChar
// AnnotationKey AKeyChar
@@ -2205,7 +2201,7 @@ TemporalParser<CharT>::annotationKey() {
template <typename CharT>
mozilla::Result<AnnotationValue, ParserError>
TemporalParser<CharT>::annotationValue() {
- // AnnotationValue :
+ // AnnotationValue :::
// AnnotationValueComponent
// AnnotationValueComponent - AnnotationValue
@@ -2222,7 +2218,7 @@ TemporalParser<CharT>::annotationValue() {
template <typename CharT>
mozilla::Result<Annotation, ParserError> TemporalParser<CharT>::annotation() {
- // Annotation :
+ // Annotation :::
// [ AnnotationCriticalFlag? AnnotationKey = AnnotationValue ]
if (!character('[')) {
@@ -2255,7 +2251,7 @@ mozilla::Result<Annotation, ParserError> TemporalParser<CharT>::annotation() {
template <typename CharT>
mozilla::Result<CalendarName, ParserError>
TemporalParser<CharT>::annotations() {
- // Annotations:
+ // Annotations :::
// Annotation Annotations?
MOZ_ASSERT(hasAnnotationStart());
@@ -2269,9 +2265,6 @@ TemporalParser<CharT>::annotations() {
}
auto [key, value, critical] = anno.unwrap();
- // FIXME: spec issue - ignore case for "[u-ca=" to match BCP47?
- // https://github.com/tc39/proposal-temporal/issues/2524
-
static constexpr std::string_view ca = "u-ca";
auto keySpan = reader_.substring(key);
@@ -2295,7 +2288,7 @@ mozilla::Result<ZonedDateTimeString, ParserError>
TemporalParser<CharT>::annotatedTime() {
// clang-format off
//
- // AnnotatedTime :
+ // AnnotatedTime :::
// TimeDesignator TimeSpec DateTimeUTCOffset? TimeZoneAnnotation? Annotations?
// TimeSpecWithOptionalOffsetNotAmbiguous TimeZoneAnnotation? Annotations?
//
@@ -2339,7 +2332,7 @@ TemporalParser<CharT>::annotatedTime() {
// clang-format off
//
- // TimeSpecWithOptionalOffsetNotAmbiguous :
+ // TimeSpecWithOptionalOffsetNotAmbiguous :::
// TimeSpec DateTimeUTCOffset? but not one of ValidMonthDay or DateSpecYearMonth
//
// clang-format on
@@ -2407,7 +2400,7 @@ TemporalParser<CharT>::annotatedTime() {
template <typename CharT>
mozilla::Result<ZonedDateTimeString, ParserError>
TemporalParser<CharT>::annotatedDateTime() {
- // AnnotatedDateTime[Zoned] :
+ // AnnotatedDateTime[Zoned] :::
// [~Zoned] DateTime TimeZoneAnnotation? Annotations?
// [+Zoned] DateTime TimeZoneAnnotation Annotations?
@@ -2441,7 +2434,7 @@ mozilla::Result<ZonedDateTimeString, ParserError>
TemporalParser<CharT>::annotatedDateTimeTimeRequired() {
// clang-format off
//
- // AnnotatedDateTimeTimeRequired :
+ // AnnotatedDateTimeTimeRequired :::
// Date DateTimeSeparator TimeSpec DateTimeUTCOffset? TimeZoneAnnotation? Annotations?
//
// clang-format on
@@ -2494,7 +2487,7 @@ TemporalParser<CharT>::annotatedDateTimeTimeRequired() {
template <typename CharT>
mozilla::Result<ZonedDateTimeString, ParserError>
TemporalParser<CharT>::annotatedYearMonth() {
- // AnnotatedYearMonth :
+ // AnnotatedYearMonth :::
// DateSpecYearMonth TimeZoneAnnotation? Annotations?
ZonedDateTimeString result = {};
@@ -2527,7 +2520,7 @@ TemporalParser<CharT>::annotatedYearMonth() {
template <typename CharT>
mozilla::Result<ZonedDateTimeString, ParserError>
TemporalParser<CharT>::annotatedMonthDay() {
- // AnnotatedMonthDay :
+ // AnnotatedMonthDay :::
// DateSpecMonthDay TimeZoneAnnotation? Annotations?
ZonedDateTimeString result = {};
@@ -2560,11 +2553,11 @@ TemporalParser<CharT>::annotatedMonthDay() {
template <typename CharT>
mozilla::Result<PlainDate, ParserError>
TemporalParser<CharT>::dateSpecYearMonth() {
- // DateSpecYearMonth :
+ // DateSpecYearMonth :::
// DateYear -? DateMonth
PlainDate result = {};
- // DateYear :
+ // DateYear :::
// DecimalDigit{4}
// Sign DecimalDigit{6}
if (auto year = digits(4)) {
@@ -2585,7 +2578,7 @@ TemporalParser<CharT>::dateSpecYearMonth() {
character('-');
- // DateMonth :
+ // DateMonth :::
// 0 NonzeroDigit
// 10
// 11
@@ -2608,16 +2601,17 @@ TemporalParser<CharT>::dateSpecYearMonth() {
template <typename CharT>
mozilla::Result<PlainDate, ParserError>
TemporalParser<CharT>::dateSpecMonthDay() {
- // DateSpecMonthDay :
+ // DateSpecMonthDay :::
// -- DateMonth -? DateDay
// DateMonth -? DateDay
PlainDate result = {};
+ // Optional: --
string("--");
result.year = AbsentYear;
- // DateMonth :
+ // DateMonth :::
// 0 NonzeroDigit
// 10
// 11
@@ -2631,9 +2625,10 @@ TemporalParser<CharT>::dateSpecMonthDay() {
return mozilla::Err(JSMSG_TEMPORAL_PARSER_MISSING_MONTH);
}
+ // Optional: -
character('-');
- // DateDay :
+ // DateDay :::
// 0 NonzeroDigit
// 1 DecimalDigit
// 2 DecimalDigit
@@ -2653,19 +2648,19 @@ TemporalParser<CharT>::dateSpecMonthDay() {
template <typename CharT>
mozilla::Result<PlainDate, ParserError> TemporalParser<CharT>::validMonthDay() {
- // ValidMonthDay :
+ // ValidMonthDay :::
// DateMonth -? 0 NonZeroDigit
// DateMonth -? 1 DecimalDigit
// DateMonth -? 2 DecimalDigit
// DateMonth -? 30 but not one of 0230 or 02-30
// DateMonthWithThirtyOneDays -? 31
//
- // DateMonthWithThirtyOneDays : one of
+ // DateMonthWithThirtyOneDays ::: one of
// 01 03 05 07 08 10 12
PlainDate result = {};
- // DateMonth :
+ // DateMonth :::
// 0 NonzeroDigit
// 10
// 11
@@ -2679,6 +2674,7 @@ mozilla::Result<PlainDate, ParserError> TemporalParser<CharT>::validMonthDay() {
return mozilla::Err(JSMSG_TEMPORAL_PARSER_MISSING_MONTH);
}
+ // Optional: -
character('-');
if (auto day = digits(2)) {
@@ -2834,7 +2830,7 @@ JSLinearString* js::temporal::ParseTemporalCalendarString(
template <typename CharT>
mozilla::Result<ZonedDateTimeString, ParserError>
TemporalParser<CharT>::parseTemporalTimeString() {
- // TemporalTimeString :
+ // TemporalTimeString :::
// AnnotatedTime
// AnnotatedDateTimeTimeRequired
@@ -2915,7 +2911,7 @@ bool js::temporal::ParseTemporalTimeString(JSContext* cx, Handle<JSString*> str,
template <typename CharT>
mozilla::Result<ZonedDateTimeString, ParserError>
TemporalParser<CharT>::parseTemporalMonthDayString() {
- // TemporalMonthDayString :
+ // TemporalMonthDayString :::
// AnnotatedMonthDay
// AnnotatedDateTime[~Zoned]
@@ -3014,7 +3010,7 @@ bool js::temporal::ParseTemporalMonthDayString(
template <typename CharT>
mozilla::Result<ZonedDateTimeString, ParserError>
TemporalParser<CharT>::parseTemporalYearMonthString() {
- // TemporalYearMonthString :
+ // TemporalYearMonthString :::
// AnnotatedYearMonth
// AnnotatedDateTime[~Zoned]
@@ -3112,7 +3108,7 @@ bool js::temporal::ParseTemporalYearMonthString(
template <typename CharT>
mozilla::Result<ZonedDateTimeString, ParserError>
TemporalParser<CharT>::parseTemporalDateTimeString() {
- // TemporalDateTimeString[Zoned] :
+ // TemporalDateTimeString[Zoned] :::
// AnnotatedDateTime[?Zoned]
auto dateTime = annotatedDateTime();
@@ -3209,10 +3205,10 @@ mozilla::Result<ZonedDateTimeString, ParserError>
TemporalParser<CharT>::parseTemporalZonedDateTimeString() {
// Parse goal: TemporalDateTimeString[+Zoned]
//
- // TemporalDateTimeString[Zoned] :
+ // TemporalDateTimeString[Zoned] :::
// AnnotatedDateTime[?Zoned]
//
- // AnnotatedDateTime[Zoned] :
+ // AnnotatedDateTime[Zoned] :::
// [~Zoned] DateTime TimeZoneAnnotation? Annotations?
// [+Zoned] DateTime TimeZoneAnnotation Annotations?
@@ -3269,7 +3265,7 @@ static auto ParseTemporalZonedDateTimeString(Handle<JSLinearString*> str) {
bool js::temporal::ParseTemporalZonedDateTimeString(
JSContext* cx, Handle<JSString*> str, PlainDateTime* dateTime, bool* isUTC,
bool* hasOffset, int64_t* timeZoneOffset,
- MutableHandle<ParsedTimeZone> timeZoneName,
+ MutableHandle<ParsedTimeZone> timeZoneAnnotation,
MutableHandle<JSString*> calendar) {
Rooted<JSLinearString*> linear(cx, str->ensureLinear(cx));
if (!linear) {
@@ -3313,7 +3309,7 @@ bool js::temporal::ParseTemporalZonedDateTimeString(
// { [[Z]]: false, [[OffsetString]]: undefined, [[Name]]: "Europe/Berlin" }
const auto& annotation = parsed.timeZone.annotation;
- if (!ParseTimeZoneAnnotation(cx, annotation, linear, timeZoneName)) {
+ if (!ParseTimeZoneAnnotation(cx, annotation, linear, timeZoneAnnotation)) {
return false;
}
@@ -3370,7 +3366,7 @@ static auto ParseTemporalRelativeToString(Handle<JSLinearString*> str) {
bool js::temporal::ParseTemporalRelativeToString(
JSContext* cx, Handle<JSString*> str, PlainDateTime* dateTime, bool* isUTC,
bool* hasOffset, int64_t* timeZoneOffset,
- MutableHandle<ParsedTimeZone> timeZoneName,
+ MutableHandle<ParsedTimeZone> timeZoneAnnotation,
MutableHandle<JSString*> calendar) {
Rooted<JSLinearString*> linear(cx, str->ensureLinear(cx));
if (!linear) {
@@ -3420,7 +3416,7 @@ bool js::temporal::ParseTemporalRelativeToString(
// { [[Z]]: false, [[OffsetString]]: undefined, [[Name]]: "Europe/Berlin" }
const auto& annotation = parsed.timeZone.annotation;
- if (!ParseTimeZoneAnnotation(cx, annotation, linear, timeZoneName)) {
+ if (!ParseTimeZoneAnnotation(cx, annotation, linear, timeZoneAnnotation)) {
return false;
}
@@ -3444,7 +3440,7 @@ bool js::temporal::ParseTemporalRelativeToString(
*isUTC = false;
*hasOffset = false;
*timeZoneOffset = 0;
- timeZoneName.set(ParsedTimeZone{});
+ timeZoneAnnotation.set(ParsedTimeZone{});
}
// Step 4. (ParseISODateTime, steps 23-24.)