mirror of
https://github.com/fergalmoran/ladybird.git
synced 2026-01-02 22:55:23 +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:
committed by
Linus Groh
parent
c7e021c1f1
commit
548643bcc9
14
AK/Time.cpp
14
AK/Time.cpp
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user