1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 08:27:46 +00:00

LibJS: Use required fields argument in ISOYearMonthFromFields

This is an editorial change in the Temporal spec.

See: ff02f87
This commit is contained in:
Linus Groh 2022-05-17 21:16:56 +01:00
parent 0946f82c8c
commit a5c41aa905

View file

@ -764,23 +764,19 @@ ThrowCompletionOr<ISOYearMonth> iso_year_month_from_fields(GlobalObject& global_
// 2. Let overflow be ? ToTemporalOverflow(options).
auto overflow = TRY(to_temporal_overflow(global_object, &options));
// 3. Set fields to ? PrepareTemporalFields(fields, « "month", "monthCode", "year" », «»).
auto* prepared_fields = TRY(prepare_temporal_fields(global_object, fields, { "month"sv, "monthCode"sv, "year"sv }, {}));
// 3. Set fields to ? PrepareTemporalFields(fields, « "month", "monthCode", "year" », « "year" »).
auto* prepared_fields = TRY(prepare_temporal_fields(global_object, fields, { "month"sv, "monthCode"sv, "year"sv }, { "year"sv }));
// 4. Let year be ! Get(fields, "year").
auto year = MUST(prepared_fields->get(vm.names.year));
// 5. If year is undefined, throw a TypeError exception.
if (year.is_undefined())
return vm.throw_completion<TypeError>(global_object, ErrorType::MissingRequiredProperty, vm.names.year.as_string());
// 6. Let month be ? ResolveISOMonth(fields).
// 5. Let month be ? ResolveISOMonth(fields).
auto month = TRY(resolve_iso_month(global_object, *prepared_fields));
// 7. Let result be ? RegulateISOYearMonth(year, month, overflow).
// 6. Let result be ? RegulateISOYearMonth(year, month, overflow).
auto result = TRY(regulate_iso_year_month(global_object, year.as_double(), month, overflow));
// 8. Return the Record { [[Year]]: result.[[Year]], [[Month]]: result.[[Month]], [[ReferenceISODay]]: 1 }.
// 7. Return the Record { [[Year]]: result.[[Year]], [[Month]]: result.[[Month]], [[ReferenceISODay]]: 1 }.
return ISOYearMonth { .year = result.year, .month = result.month, .reference_iso_day = 1 };
}