1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 18:08:12 +00:00

AK+LibC+LibCore: Add a days_in_year function

This commit is contained in:
Nico Weber 2020-08-25 20:17:19 -04:00 committed by Andreas Kling
parent a7a18b478e
commit 2236385e1f
3 changed files with 13 additions and 8 deletions

View file

@ -216,8 +216,7 @@ String DateTime::to_string(const String& format) const
if (tm.tm_yday >= 7 - wday_of_year_beginning)
--week_number;
else {
const bool last_year_is_leap = ::is_leap_year(tm.tm_year + 1900 - 1);
const int days_of_last_year = 365 + last_year_is_leap;
const int days_of_last_year = days_in_year(tm.tm_year + 1900 - 1);
const int wday_of_last_year_beginning = (wday_of_year_beginning + 6 * days_of_last_year) % 7;
week_number = (days_of_last_year + wday_of_last_year_beginning) / 7 + 1;
if (wday_of_last_year_beginning > 3)