1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 07:38:10 +00:00

AK: Redeclare a few AK::Time helpers as constexpr

This is to allow using these methods within an upcoming constexpr
factory method.
This commit is contained in:
Timothy Flynn 2022-01-10 22:38:48 -05:00 committed by Linus Groh
parent c7e021c1f1
commit 548643bcc9
2 changed files with 21 additions and 23 deletions

View file

@ -4,7 +4,6 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <AK/Array.h>
#include <AK/Checked.h>
#include <AK/Time.h>
@ -19,19 +18,6 @@
namespace AK {
int day_of_year(int year, unsigned month, int day)
{
VERIFY(month >= 1 && month <= 12);
constexpr Array seek_table = { 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334 };
int day_of_year = seek_table[month - 1] + day - 1;
if (is_leap_year(year) && month >= 3)
day_of_year++;
return day_of_year;
}
int days_in_month(int year, unsigned month)
{
VERIFY(month >= 1 && month <= 12);