mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-01-24 02:03:06 -05:00
LibCore: Use is_leap_year more in DateTime
This commit is contained in:
parent
4dfe97f9ae
commit
dcb81fc199
Notes:
sideshowbarker
2024-07-19 03:08:31 +09:00
Author: https://github.com/nico Commit: https://github.com/SerenityOS/serenity/commit/dcb81fc1999 Pull-request: https://github.com/SerenityOS/serenity/pull/3307
1 changed files with 1 additions and 1 deletions
|
@ -221,7 +221,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 = ((tm.tm_year + 1900 - 1) % 4 == 0 && (tm.tm_year + 1900 - 1) % 100 != 0) || (tm.tm_year + 1900 - 1) % 400 == 0;
|
||||
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 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;
|
||||
|
|
Loading…
Add table
Reference in a new issue