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

Everywhere: Deduplicate day/month name constants

Day and month name constants are defined in numerous places. This
pulls them together into a single place and eliminates the
duplication. It also ensures they are `constexpr`.
This commit is contained in:
Lenny Maiorani 2022-03-16 19:08:53 -06:00 committed by Linus Groh
parent 759857b597
commit 4c5e9f5633
7 changed files with 79 additions and 134 deletions

47
AK/DateConstants.h Normal file
View file

@ -0,0 +1,47 @@
/*
* Copyright (c) 2022, the SerenityOS developers.
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <AK/Array.h>
#include <AK/StringView.h>
namespace AK {
static constexpr Array<StringView, 7> long_day_names = {
"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"
};
static constexpr Array<StringView, 7> short_day_names = {
"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"
};
static constexpr Array<StringView, 7> mini_day_names = {
"Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"
};
static constexpr Array<StringView, 7> micro_day_names = {
"S", "M", "T", "W", "T", "F", "S"
};
static constexpr Array<StringView, 12> long_month_names = {
"January", "February", "March", "April", "May", "June",
"July", "August", "September", "October", "November", "December"
};
static constexpr Array<StringView, 12> short_month_names = {
"Jan", "Feb", "Mar", "Apr", "May", "Jun",
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
};
}
using AK::long_day_names;
using AK::long_month_names;
using AK::micro_day_names;
using AK::mini_day_names;
using AK::short_day_names;
using AK::short_month_names;