mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-21 20:15:17 +00:00
LibJS: Use modulo() function in to_iso_day_of_week
No behavior change.
This commit is contained in:
parent
b87ab989a3
commit
481f7d6afa
Notes:
sideshowbarker
2024-07-18 01:05:40 +09:00
Author: https://github.com/nico Commit: https://github.com/SerenityOS/serenity/commit/481f7d6afa8 Pull-request: https://github.com/SerenityOS/serenity/pull/10932 Reviewed-by: https://github.com/linusg ✅
1 changed files with 1 additions and 4 deletions
|
@ -665,10 +665,7 @@ u8 to_iso_day_of_week(i32 year, u8 month, u8 day)
|
|||
auto normalized_year = year - (month < 3 ? 1 : 0);
|
||||
auto century = normalized_year / 100;
|
||||
auto truncated_year = normalized_year - (century * 100);
|
||||
auto result = (day + static_cast<u8>((2.6 * normalized_month) - 0.2) - (2 * century) + truncated_year + (truncated_year / 4) + (century / 4)) % 7;
|
||||
if (result <= 0) // Mathematical modulo
|
||||
result += 7;
|
||||
return result;
|
||||
return modulo(day + static_cast<u8>((2.6 * normalized_month) - 0.2) - (2 * century) + truncated_year + (truncated_year / 4) + (century / 4), 7);
|
||||
}
|
||||
|
||||
// 12.1.34 ToISODayOfYear ( year, month, day ), https://tc39.es/proposal-temporal/#sec-temporal-toisodayofyear
|
||||
|
|
Loading…
Add table
Reference in a new issue