Convert DateTimeConstants constants to enum cases

This commit is contained in:
netkas 2024-09-14 08:34:34 -04:00
parent 9c06378258
commit 492548d81f
2 changed files with 61 additions and 61 deletions

View file

@ -178,36 +178,36 @@
}
return str_replace([
DateTimeConstants::d,
DateTimeConstants::D,
DateTimeConstants::j,
DateTimeConstants::l,
DateTimeConstants::N,
DateTimeConstants::S,
DateTimeConstants::w,
DateTimeConstants::z,
DateTimeConstants::W,
DateTimeConstants::F,
DateTimeConstants::m,
DateTimeConstants::M,
DateTimeConstants::n,
DateTimeConstants::t,
DateTimeConstants::L,
DateTimeConstants::o,
DateTimeConstants::Y,
DateTimeConstants::y,
DateTimeConstants::a,
DateTimeConstants::A,
DateTimeConstants::B,
DateTimeConstants::g,
DateTimeConstants::G,
DateTimeConstants::h,
DateTimeConstants::H,
DateTimeConstants::i,
DateTimeConstants::s,
DateTimeConstants::c,
DateTimeConstants::r,
DateTimeConstants::u
DateTimeConstants::d->value,
DateTimeConstants::D->value,
DateTimeConstants::j->value,
DateTimeConstants::l->value,
DateTimeConstants::N->value,
DateTimeConstants::S->value,
DateTimeConstants::w->value,
DateTimeConstants::z->value,
DateTimeConstants::W->value,
DateTimeConstants::F->value,
DateTimeConstants::m->value,
DateTimeConstants::M->value,
DateTimeConstants::n->value,
DateTimeConstants::t->value,
DateTimeConstants::L->value,
DateTimeConstants::o->value,
DateTimeConstants::Y->value,
DateTimeConstants::y->value,
DateTimeConstants::a->value,
DateTimeConstants::A->value,
DateTimeConstants::B->value,
DateTimeConstants::g->value,
DateTimeConstants::G->value,
DateTimeConstants::h->value,
DateTimeConstants::H->value,
DateTimeConstants::i->value,
DateTimeConstants::s->value,
DateTimeConstants::c->value,
DateTimeConstants::r->value,
DateTimeConstants::u->value
],
[
date('d', $timestamp),

View file

@ -22,49 +22,49 @@
namespace ncc\Enums\SpecialConstants;
final class DateTimeConstants
enum DateTimeConstants : string
{
// Day Format
/**
* Day of the month, 2 digits with leading zeros
*/
public const d = '%d%'; // 01 through 31
case d = '%d%'; // 01 through 31
/**
* A textual representation of a day, three letters
*/
public const D = '%D%'; // Mon through Sun
case D = '%D%'; // Mon through Sun
/**
* Day of the month without leading zeros
*/
public const j = '%j%'; // 1 through 31
case j = '%j%'; // 1 through 31
/**
* A full textual representation of the day of the week
*/
public const l = '%l%'; // Sunday through Saturday
case l = '%l%'; // Sunday through Saturday
/**
* ISO 8601 numeric representation of the day of the week
*/
public const N = '%N%'; // 1 (Monday) to 7 (Sunday)
case N = '%N%'; // 1 (Monday) to 7 (Sunday)
/**
* English ordinal suffix for the day of the month, 2 characters
*/
public const S = '%S%'; // st, nd, rd, th
case S = '%S%'; // st, nd, rd, th
/**
* Numeric representation of the day of the week
*/
public const w = '%w%'; // 0 (sunday) through 6 (Saturday)
case w = '%w%'; // 0 (sunday) through 6 (Saturday)
/**
* The day of the year (starting from 0)
*/
public const z = '%z%'; // 0 through 365
case z = '%z%'; // 0 through 365
@ -73,7 +73,7 @@
/**
* ISO 8601 week number of year, weeks starting on Monday
*/
public const W = '%W%'; // 42 (42nd week in year)
case W = '%W%'; // 42 (42nd week in year)
@ -82,27 +82,27 @@
/**
* A full textual representation of a month, such as January or March
*/
public const F = '%F%'; // January through December
case F = '%F%'; // January through December
/**
* Numeric representation of a month, with leading zeros
*/
public const m = '%m%'; // 01 through 12
case m = '%m%'; // 01 through 12
/**
* A short textual representation of a month, three letters
*/
public const M = '%M%'; // Jan through Dec
case M = '%M%'; // Jan through Dec
/**
* Numeric representation of a month, without leading zeros
*/
public const n = '%n%'; // 1 through 12
case n = '%n%'; // 1 through 12
/**
* Number of days in the given month
*/
public const t = '%t%'; // 28 through 31
case t = '%t%'; // 28 through 31
@ -110,73 +110,73 @@
/**
* Whether it's a leap year
*/
public const L = '%L%'; // 1 (leap year), 0 otherwise
case L = '%L%'; // 1 (leap year), 0 otherwise
/**
* ISO 8601 week-numbering year. This has the same value as Y,
* except that if the ISO week number (W) belongs to the previous
* or next year, that year is used instead.
*/
public const o = '%o%'; // Same as Y, except that it use week number to decide which year it falls onto
case o = '%o%'; // Same as Y, except that it use week number to decide which year it falls onto
/**
* A full numeric representation of a year, at least 4 digits, with - for years BCE.
*/
public const Y = '%Y%'; // 1991, 2012, 2014, ...
case Y = '%Y%'; // 1991, 2012, 2014, ...
/**
* A two digit representation of a year
*/
public const y = '%y%'; // 91, 12, 14, ...
case y = '%y%'; // 91, 12, 14, ...
// Time Format
/**
* Lowercase Ante meridiem and Post meridiem
*/
public const a = '%a%'; // am or pm
case a = '%a%'; // am or pm
/**
* Uppercase Ante meridiem and Post meridiem
*/
public const A = '%A%'; // AM or PM
case A = '%A%'; // AM or PM
/**
* Swatch Internet time
*/
public const B = '%B%'; // 000 through 999
case B = '%B%'; // 000 through 999
/**
* 12-hour format of an hour without leading zeros
*/
public const g = '%g%'; // 1 through 12
case g = '%g%'; // 1 through 12
/**
* 24-hour format of an hour without leading zeros
*/
public const G = '%G%'; // 0 through 23
case G = '%G%'; // 0 through 23
/**
* 12-hour format of an hour with leading zeros
*/
public const h = '%h%'; // 01 through 12
case h = '%h%'; // 01 through 12
/**
* 24-hour format of an hour with leading zeros
*/
public const H = '%H%'; // 01 through 23
case H = '%H%'; // 01 through 23
/**
* Minutes with leading zeros
*/
public const i = '%i%'; // 01 through 59
case i = '%i%'; // 01 through 59
/**
* Seconds with leading zeros
*/
public const s = '%s%'; // 00 through 59
case s = '%s%'; // 00 through 59
// DateTime format
public const c = '%c%'; // 2004-02-12T15:19:21
public const r = '%r%'; // Thu, 21 Dec 2000 16:01:07
public const u = '%u%'; // Unix Timestamp (seconds since Jan 1 1970 00:00:00)
case c = '%c%'; // 2004-02-12T15:19:21
case r = '%r%'; // Thu, 21 Dec 2000 16:01:07
case u = '%u%'; // Unix Timestamp (seconds since Jan 1 1970 00:00:00)
}