From 9a60d3509d978d3ae14e1badecbe8d4d351f230b Mon Sep 17 00:00:00 2001 From: BodilessSleeper Date: Tue, 10 Jan 2023 03:58:20 +0100 Subject: [PATCH] LibJS: Update ISODaysInMonth in Calendar.cpp This commit ticks away a box in #15525 Temporal commit: tc39/proposal-temporal@eee1e27 --- .../Libraries/LibJS/Runtime/Temporal/Calendar.cpp | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/Calendar.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/Calendar.cpp index 685bb7726af..baa0dbcae27 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/Calendar.cpp +++ b/Userland/Libraries/LibJS/Runtime/Temporal/Calendar.cpp @@ -652,20 +652,18 @@ ThrowCompletionOr 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)); }