summaryrefslogtreecommitdiff
path: root/Libraries
diff options
context:
space:
mode:
authorNico Weber <thakis@chromium.org>2020-08-25 19:35:48 -0400
committerAndreas Kling <kling@serenityos.org>2020-08-26 08:52:07 +0200
commitdcb81fc1999f468c723a62fb29696f908d859081 (patch)
tree5cf61dfefebe475060317a69a14c964c6a696351 /Libraries
parent4dfe97f9ae8de71ff6cb87f0a8ce2c5e7ca79c2e (diff)
downloadserenity-dcb81fc1999f468c723a62fb29696f908d859081.zip
LibCore: Use is_leap_year more in DateTime
Diffstat (limited to 'Libraries')
-rw-r--r--Libraries/LibCore/DateTime.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/Libraries/LibCore/DateTime.cpp b/Libraries/LibCore/DateTime.cpp
index c4062699cc..3cd4ccc870 100644
--- a/Libraries/LibCore/DateTime.cpp
+++ b/Libraries/LibCore/DateTime.cpp
@@ -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;