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

View file

@ -22,49 +22,49 @@
namespace ncc\Enums\SpecialConstants; namespace ncc\Enums\SpecialConstants;
final class DateTimeConstants enum DateTimeConstants : string
{ {
// Day Format // Day Format
/** /**
* Day of the month, 2 digits with leading zeros * 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 * 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 * 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 * 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 * 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 * 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 * 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) * 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 * 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 * 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 * 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 * 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 * 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 * 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 * 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, * ISO 8601 week-numbering year. This has the same value as Y,
* except that if the ISO week number (W) belongs to the previous * except that if the ISO week number (W) belongs to the previous
* or next year, that year is used instead. * 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. * 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 * A two digit representation of a year
*/ */
public const y = '%y%'; // 91, 12, 14, ... case y = '%y%'; // 91, 12, 14, ...
// Time Format // Time Format
/** /**
* Lowercase Ante meridiem and Post meridiem * 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 * Uppercase Ante meridiem and Post meridiem
*/ */
public const A = '%A%'; // AM or PM case A = '%A%'; // AM or PM
/** /**
* Swatch Internet time * 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 * 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 * 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 * 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 * 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 * Minutes with leading zeros
*/ */
public const i = '%i%'; // 01 through 59 case i = '%i%'; // 01 through 59
/** /**
* Seconds with leading zeros * Seconds with leading zeros
*/ */
public const s = '%s%'; // 00 through 59 case s = '%s%'; // 00 through 59
// DateTime format // DateTime format
public const c = '%c%'; // 2004-02-12T15:19:21 case c = '%c%'; // 2004-02-12T15:19:21
public const r = '%r%'; // Thu, 21 Dec 2000 16:01:07 case r = '%r%'; // Thu, 21 Dec 2000 16:01:07
public const u = '%u%'; // Unix Timestamp (seconds since Jan 1 1970 00:00:00) case u = '%u%'; // Unix Timestamp (seconds since Jan 1 1970 00:00:00)
} }