diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/PlainMonthDay.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/PlainMonthDay.cpp index 85d21549e9..fbf8d44b25 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/PlainMonthDay.cpp +++ b/Userland/Libraries/LibJS/Runtime/Temporal/PlainMonthDay.cpp @@ -155,18 +155,22 @@ ThrowCompletionOr create_temporal_month_day(GlobalObject& global if (!is_valid_iso_date(reference_iso_year, iso_month, iso_day)) return vm.throw_completion(global_object, ErrorType::TemporalInvalidPlainMonthDay); - // 4. If newTarget is not present, set newTarget to %Temporal.PlainMonthDay%. + // 4. If ISODateTimeWithinLimits(referenceISOYear, isoMonth, isoDay, 12, 0, 0, 0, 0, 0) is false, throw a RangeError exception. + if (!iso_date_time_within_limits(global_object, reference_iso_year, iso_month, iso_day, 12, 0, 0, 0, 0, 0)) + return vm.throw_completion(global_object, ErrorType::TemporalInvalidPlainMonthDay); + + // 5. If newTarget is not present, set newTarget to %Temporal.PlainMonthDay%. if (!new_target) new_target = global_object.temporal_plain_month_day_constructor(); - // 5. Let object be ? OrdinaryCreateFromConstructor(newTarget, "%Temporal.PlainMonthDay.prototype%", « [[InitializedTemporalMonthDay]], [[ISOMonth]], [[ISODay]], [[ISOYear]], [[Calendar]] »). - // 6. Set object.[[ISOMonth]] to isoMonth. - // 7. Set object.[[ISODay]] to isoDay. - // 8. Set object.[[Calendar]] to calendar. - // 9. Set object.[[ISOYear]] to referenceISOYear. + // 6. Let object be ? OrdinaryCreateFromConstructor(newTarget, "%Temporal.PlainMonthDay.prototype%", « [[InitializedTemporalMonthDay]], [[ISOMonth]], [[ISODay]], [[ISOYear]], [[Calendar]] »). + // 7. Set object.[[ISOMonth]] to isoMonth. + // 8. Set object.[[ISODay]] to isoDay. + // 9. Set object.[[Calendar]] to calendar. + // 10. Set object.[[ISOYear]] to referenceISOYear. auto* object = TRY(ordinary_create_from_constructor(global_object, *new_target, &GlobalObject::temporal_plain_month_day_prototype, iso_month, iso_day, reference_iso_year, calendar)); - // 10. Return object. + // 11. Return object. return object; } diff --git a/Userland/Libraries/LibJS/Tests/builtins/Temporal/PlainMonthDay/PlainMonthDay.js b/Userland/Libraries/LibJS/Tests/builtins/Temporal/PlainMonthDay/PlainMonthDay.js index fc5b315382..109d01e28f 100644 --- a/Userland/Libraries/LibJS/Tests/builtins/Temporal/PlainMonthDay/PlainMonthDay.js +++ b/Userland/Libraries/LibJS/Tests/builtins/Temporal/PlainMonthDay/PlainMonthDay.js @@ -37,6 +37,12 @@ describe("errors", () => { new Temporal.PlainMonthDay(1, 0); }).toThrowWithMessage(RangeError, "Invalid plain month day"); }); + + test("not within iso date time limit", () => { + expect(() => { + new Temporal.PlainMonthDay(9, 30, "iso8601", 999_999_999_999_999); + }).toThrowWithMessage(RangeError, "Invalid plain month day"); + }); }); describe("normal behavior", () => {