mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-26 09:30:24 +00:00
LibJS: Update ISODaysInMonth in Calendar.cpp
This commit ticks away a box in #15525 Temporal commit: tc39/proposal-temporal@eee1e27
This commit is contained in:
parent
7e3625b0e2
commit
9a60d3509d
Notes:
sideshowbarker
2024-07-17 12:02:22 +09:00
Author: https://github.com/BodilessSleeper Commit: https://github.com/SerenityOS/serenity/commit/9a60d3509d Pull-request: https://github.com/SerenityOS/serenity/pull/16940 Reviewed-by: https://github.com/linusg
1 changed files with 6 additions and 8 deletions
|
@ -652,20 +652,18 @@ ThrowCompletionOr<Object*> consolidate_calendars(VM& vm, Object& one, Object& tw
|
|||
// 12.2.31 ISODaysInMonth ( year, month ), https://tc39.es/proposal-temporal/#sec-temporal-isodaysinmonth
|
||||
u8 iso_days_in_month(i32 year, u8 month)
|
||||
{
|
||||
// 1. Assert: year is an integer.
|
||||
|
||||
// 2. Assert: month is an integer, month ≥ 1, and month ≤ 12.
|
||||
VERIFY(month >= 1 && month <= 12);
|
||||
|
||||
// 3. If month is 1, 3, 5, 7, 8, 10, or 12, return 31.
|
||||
// 1. If month is 1, 3, 5, 7, 8, 10, or 12, return 31.
|
||||
if (month == 1 || month == 3 || month == 5 || month == 7 || month == 8 || month == 10 || month == 12)
|
||||
return 31;
|
||||
|
||||
// 4. If month is 4, 6, 9, or 11, return 30.
|
||||
// 2. If month is 4, 6, 9, or 11, return 30.
|
||||
if (month == 4 || month == 6 || month == 9 || month == 11)
|
||||
return 30;
|
||||
|
||||
// 5. Return 28 + ℝ(InLeapYear(TimeFromYear(𝔽(year)))).
|
||||
// 3. Assert: month is 2.
|
||||
VERIFY(month == 2);
|
||||
|
||||
// 4. Return 28 + ℝ(InLeapYear(TimeFromYear(𝔽(year)))).
|
||||
return 28 + JS::in_leap_year(time_from_year(year));
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue