From a808cd163172144a4b82a4b050d28d686bb04877 Mon Sep 17 00:00:00 2001 From: Shannon Booth Date: Sat, 15 Feb 2025 20:11:07 +1300 Subject: [PATCH] AK: Add a 'weeks_in_year' helper A week variant of the pre-existing 'days_in_year'. --- AK/Time.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/AK/Time.h b/AK/Time.h index 83d20099004..8ac8502eaa5 100644 --- a/AK/Time.h +++ b/AK/Time.h @@ -77,6 +77,11 @@ constexpr int days_in_year(int year) return 365 + (is_leap_year(year) ? 1 : 0); } +constexpr int weeks_in_year(int year) +{ + return is_leap_year(year) ? 53 : 52; +} + namespace Detail { // Integer division rounding towards negative infinity. // TODO: This feels like there should be an easier way to do this. @@ -602,5 +607,6 @@ using AK::timeval_add; using AK::timeval_sub; using AK::timeval_to_timespec; using AK::UnixDateTime; +using AK::weeks_in_year; using AK::years_to_days_since_epoch; #endif