mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-09 09:39:39 +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: a808cd1631
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);
|
return 365 + (is_leap_year(year) ? 1 : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
constexpr int weeks_in_year(int year)
|
||||||
|
{
|
||||||
|
return is_leap_year(year) ? 53 : 52;
|
||||||
|
}
|
||||||
|
|
||||||
namespace Detail {
|
namespace Detail {
|
||||||
// Integer division rounding towards negative infinity.
|
// Integer division rounding towards negative infinity.
|
||||||
// TODO: This feels like there should be an easier way to do this.
|
// 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_sub;
|
||||||
using AK::timeval_to_timespec;
|
using AK::timeval_to_timespec;
|
||||||
using AK::UnixDateTime;
|
using AK::UnixDateTime;
|
||||||
|
using AK::weeks_in_year;
|
||||||
using AK::years_to_days_since_epoch;
|
using AK::years_to_days_since_epoch;
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue