mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-21 20:15:17 +00:00
AK: Add a 'weeks_in_year' helper
A week variant of the pre-existing 'days_in_year'.
This commit is contained in:
parent
ad8a0e4940
commit
a808cd1631
Notes:
github-actions[bot]
2025-02-22 19:10:45 +00:00
Author: https://github.com/shannonbooth Commit: https://github.com/LadybirdBrowser/ladybird/commit/a808cd16317 Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/3485 Reviewed-by: https://github.com/AtkinsSJ ✅ Reviewed-by: https://github.com/gmta Reviewed-by: https://github.com/trflynn89
1 changed files with 6 additions and 0 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue