diff --git a/polyfill/lib/ecmascript.mjs b/polyfill/lib/ecmascript.mjs index 8ab14c676..363f968c8 100644 --- a/polyfill/lib/ecmascript.mjs +++ b/polyfill/lib/ecmascript.mjs @@ -436,6 +436,12 @@ export function ParseISODateTime(isoString) { const day = +match.groups.daypart; assert(month !== undefined && day !== undefined, `Month and day must be present if string ${isoString} matched`); 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); @@ -491,6 +497,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; assert(hour !== undefined, `Hour must be present if string ${isoString} matched`); minute = +(match.groups.minute ?? 0); diff --git a/polyfill/test262 b/polyfill/test262 index 0d3ca0dc5..249ef0e4b 160000 --- a/polyfill/test262 +++ b/polyfill/test262 @@ -1 +1 @@ -Subproject commit 0d3ca0dc5067aeef645d46c72817a811b7388149 +Subproject commit 249ef0e4b5ee86c0440e4ce383f12d5811eb5eaa