Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions polyfill/lib/ecmascript.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,12 @@ export function ParseISODateTime(isoString) {
const month = +(match.groups.monthpart ?? 1);
const day = +(match.groups.daypart ?? 1);
const hasTime = match.groups.hour !== undefined;
const hasMinute = match.groups.minute !== undefined;
const hasSecond = match.groups.second !== undefined;
const hasFraction = match.groups.fraction !== undefined;
if (hasFraction && (!hasSecond || (!hasMinute && hasTime))) {
throw new RangeErrorCtor(`invalid RFC 9557 string: ${isoString}, only seconds may be fractional`);
}
const hour = +(match.groups.hour ?? 0);
const minute = +(match.groups.minute ?? 0);
let second = +(match.groups.second ?? 0);
Expand Down Expand Up @@ -492,6 +498,13 @@ export function ParseTemporalTimeString(isoString) {
let hour, minute, second, millisecond, microsecond, nanosecond, calendar;
if (match) {
calendar = processAnnotations(match.groups.annotation);
const hasFraction = match.groups.fraction !== undefined;
const hasSecond = match.groups.second !== undefined;
const hasMinute = match.groups.minute !== undefined;
const hasHour = match.groups.hour !== undefined;
if (hasFraction && (!hasSecond || (!hasMinute && hasHour))) {
throw new RangeErrorCtor(`invalid RFC 9557 string: ${isoString}, only seconds may be fractional`);
}
hour = +(match.groups.hour ?? 0);
minute = +(match.groups.minute ?? 0);
second = +(match.groups.second ?? 0);
Expand Down