mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-28 19:59:17 +00:00
AK+LibC+LibCore: Have fewer implementations of days_in_month
This commit is contained in:
parent
dcb81fc199
commit
a7a18b478e
Notes:
sideshowbarker
2024-07-19 03:08:27 +09:00
Author: https://github.com/nico
Commit: a7a18b478e
Pull-request: https://github.com/SerenityOS/serenity/pull/3307
4 changed files with 20 additions and 16 deletions
|
@ -42,4 +42,13 @@ int day_of_year(int year, unsigned month, int day)
|
|||
return day_of_year;
|
||||
}
|
||||
|
||||
int days_in_month(int year, unsigned month)
|
||||
{
|
||||
ASSERT(month >= 1 && month <= 12);
|
||||
if (month == 2)
|
||||
return is_leap_year(year) ? 29 : 28;
|
||||
|
||||
bool is_long_month = (month == 1 || month == 3 || month == 5 || month == 7 || month == 8 || month == 10 || month == 12);
|
||||
return is_long_month ? 31 : 30;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue