Skip to content

Commit 3ffa677

Browse files
committed
Revert "Editorial: Move AnnotatedTime early error to a separate parse step"
This reverts commit fa3d0b9. It introduced a regression; see discussion in #3237. Closes: #3237
1 parent 137d270 commit 3ffa677

File tree

3 files changed

+29
-21
lines changed

3 files changed

+29
-21
lines changed

polyfill/test/validStrings.mjs

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,18 @@ const dateTime = (z, timeRequired) =>
315315
);
316316
const annotatedTime = choice(
317317
seq(timeDesignator, time, [dateTimeUTCOffset(false)], [timeZoneAnnotation], [annotations]),
318-
seq(time, [dateTimeUTCOffset(false)], [timeZoneAnnotation], [annotations])
318+
seq(
319+
withSyntaxConstraints(seq(time, [dateTimeUTCOffset(false)]), (result) => {
320+
if (/^(?:(?!02-?30)(?:0[1-9]|1[012])-?(?:0[1-9]|[12][0-9]|30)|(?:0[13578]|10|12)-?31)$/.test(result)) {
321+
throw new SyntaxError('valid PlainMonthDay');
322+
}
323+
if (/^(?!-000000)(?:[0-9]{4}|[+-][0-9]{6})-?(?:0[1-9]|1[012])$/.test(result)) {
324+
throw new SyntaxError('valid PlainYearMonth');
325+
}
326+
}),
327+
[timeZoneAnnotation],
328+
[annotations]
329+
)
319330
);
320331
const annotatedDateTime = (zoned, timeRequired) =>
321332
seq(dateTime(zoned, timeRequired), zoned ? timeZoneAnnotation : [timeZoneAnnotation], [annotations]);
@@ -451,20 +462,7 @@ const goals = {
451462
DateTime: annotatedDateTime(false, false),
452463
Duration: duration,
453464
MonthDay: choice(annotatedMonthDay, annotatedDateTime(false, false)),
454-
Time: withSyntaxConstraints(choice(annotatedTime, annotatedDateTime(false, true)), (result) => {
455-
try {
456-
ES.ParseTemporalMonthDayString(result);
457-
throw new SyntaxError('valid PlainMonthDay');
458-
} catch (e) {
459-
if (e instanceof SyntaxError) throw e;
460-
}
461-
try {
462-
ES.ParseTemporalYearMonthString(result);
463-
throw new SyntaxError('valid PlainYearMonth');
464-
} catch (e) {
465-
if (e instanceof SyntaxError) throw e;
466-
}
467-
}),
465+
Time: choice(annotatedTime, annotatedDateTime(false, true)),
468466
TimeZone: choice(timeZoneIdentifier, zonedDateTime, instant),
469467
YearMonth: choice(annotatedYearMonth, annotatedDateTime(false, false)),
470468
ZonedDateTime: zonedDateTime

spec/abstractops.html

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1230,7 +1230,9 @@ <h1>RFC 9557 / ISO 8601 grammar</h1>
12301230
AnnotatedTime :::
12311231
TimeDesignator Time DateTimeUTCOffset[~Z]? TimeZoneAnnotation? Annotations?
12321232
Time DateTimeUTCOffset[~Z]? TimeZoneAnnotation? Annotations?
1233-
1233+
</emu-grammar>
1234+
<p>Note the disambiguation between the second alternative without |TimeDesignator|, and |DateSpecMonthDay|/|DateSpecYearMonth| in <emu-xref href="#sec-temporal-iso8601grammar-static-semantics-early-errors"></emu-xref>.</p>
1235+
<emu-grammar type="definition">
12341236
AnnotatedDateTime[Zoned, TimeRequired] :::
12351237
[~Zoned] DateTime[~Z, ?TimeRequired] TimeZoneAnnotation? Annotations?
12361238
[+Zoned] DateTime[+Z, ?TimeRequired] TimeZoneAnnotation Annotations?
@@ -1300,10 +1302,6 @@ <h1>RFC 9557 / ISO 8601 grammar</h1>
13001302
AnnotatedTime
13011303
AnnotatedDateTime[~Zoned, +TimeRequired]
13021304

1303-
AmbiguousTemporalTimeString :::
1304-
DateSpecMonthDay TimeZoneAnnotation? Annotations?
1305-
DateSpecYearMonth TimeZoneAnnotation? Annotations?
1306-
13071305
TemporalYearMonthString :::
13081306
AnnotatedYearMonth
13091307
AnnotatedDateTime[~Zoned, ~TimeRequired]
@@ -1344,6 +1342,18 @@ <h1>Static Semantics: IsValidDate ( ): a Boolean</h1>
13441342

13451343
<emu-clause id="sec-temporal-iso8601grammar-static-semantics-early-errors">
13461344
<h1>Static Semantics: Early Errors</h1>
1345+
<emu-grammar>
1346+
AnnotatedTime :::
1347+
Time DateTimeUTCOffset[~Z]? TimeZoneAnnotation? Annotations?
1348+
</emu-grammar>
1349+
<ul>
1350+
<li>
1351+
It is a Syntax Error if ParseText(|Time| |DateTimeUTCOffset[~Z]|, |DateSpecMonthDay|) is a Parse Node.
1352+
</li>
1353+
<li>
1354+
It is a Syntax Error if ParseText(|Time| |DateTimeUTCOffset[~Z]|, |DateSpecYearMonth|) is a Parse Node.
1355+
</li>
1356+
</ul>
13471357
<emu-grammar>
13481358
DateSpec[Extended] :::
13491359
DateYear DateSeparator[?Extended] DateMonth DateSeparator[?Extended] DateDay

spec/plaintime.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -573,9 +573,9 @@ <h1>
573573
1. Else,
574574
1. If _item_ is not a String, throw a *TypeError* exception.
575575
1. Let _parseResult_ be ? ParseISODateTime(_item_, « |TemporalTimeString| »).
576-
1. If ParseText(StringToCodePoints(_item_), |AmbiguousTemporalTimeString|) is a Parse Node, throw a *RangeError* exception.
577576
1. Assert: _parseResult_.[[Time]] is not ~start-of-day~.
578577
1. Set _result_ to _parseResult_.[[Time]].
578+
1. NOTE: A successful parse using |TemporalTimeString| guarantees absence of ambiguity with respect to any ISO 8601 date-only, year-month, or month-day representation.
579579
1. Let _resolvedOptions_ be ? GetOptionsObject(_options_).
580580
1. Perform ? GetTemporalOverflowOption(_resolvedOptions_).
581581
1. Return ! CreateTemporalTime(_result_).

0 commit comments

Comments
 (0)