mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 01:37:35 +00:00
LibJS: Remove the ConstrainToRange AO
This is an editorial change in the Temporal spec.
See: 537b3e6
This commit is contained in:
parent
1521c5f55c
commit
2ad69d789b
5 changed files with 41 additions and 46 deletions
|
@ -363,12 +363,16 @@ ThrowCompletionOr<ISODate> regulate_iso_date(GlobalObject& global_object, double
|
|||
|
||||
auto y = static_cast<i32>(year);
|
||||
|
||||
// a. Set month to ! ConstrainToRange(month, 1, 12).
|
||||
month = constrain_to_range(month, 1, 12);
|
||||
// b. Set day to ! ConstrainToRange(day, 1, ! ISODaysInMonth(year, month)).
|
||||
day = constrain_to_range(day, 1, iso_days_in_month(y, month));
|
||||
// a. Set month to the result of clamping month between 1 and 12.
|
||||
month = clamp(month, 1, 12);
|
||||
|
||||
// c. Return the Record { [[Year]]: year, [[Month]]: month, [[Day]]: day }.
|
||||
// b. Let daysInMonth be ! ISODaysInMonth(year, month).
|
||||
auto days_in_month = iso_days_in_month(y, (u8)month);
|
||||
|
||||
// c. Set day to the result of clamping day between 1 and daysInMonth.
|
||||
day = clamp(day, 1, days_in_month);
|
||||
|
||||
// d. Return the Record { [[Year]]: year, [[Month]]: month, [[Day]]: day }.
|
||||
return ISODate { .year = y, .month = static_cast<u8>(month), .day = static_cast<u8>(day) };
|
||||
}
|
||||
VERIFY_NOT_REACHED();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue