1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 03:07:36 +00:00

AK+LibC+LibCore: Have fewer implementations of day_of_week

The implementation in LibC did a timestamp->day-of-week conversion
which looks like a valuable thing to have. But we only need it in
time_to_tm, where we already computed year/month/day -- so let's
consolidate on the day_of_week function in DateTime (which is
getting extracted to AK).
This commit is contained in:
Nico Weber 2020-08-25 20:32:32 -04:00 committed by Andreas Kling
parent b9cbb4fd00
commit 1ab8939077
4 changed files with 20 additions and 12 deletions

View file

@ -28,6 +28,12 @@
namespace AK {
// Month and day start at 1. Month must be >= 1 and <= 12.
// The return value is 0-indexed, that is 0 is Sunday, 1 is Monday, etc.
// Day may be negative or larger than the number of days
// in the given month.
unsigned day_of_week(int year, unsigned month, int day);
// Month and day start at 1. Month must be >= 1 and <= 12.
// The return value is 0-indexed, that is Jan 1 is day 0.
// Day may be negative or larger than the number of days
@ -176,6 +182,7 @@ inline bool operator!=(const TimespecType& a, const TimespecType& b)
}
using AK::day_of_week;
using AK::day_of_year;
using AK::days_in_month;
using AK::days_in_year;