MMO\core\dates
MMO\core\dates · 19 symbols · generated 30 Sep 2026
dateTime
dates.php:202The framework's all-purpose date parser: turns a timestamp, a DateTimeInterface, or a string into a DateTime/DateTimeImmutable, trying (in order) an explicit $format, an ISO-8601 duration (a string starting with 'P', relative to now), then PHP's own lenient string parser -- with one adjustment: for a non-MDY $language (isMDYFormat()), a dd/mm/yyyy-shaped string has its / swapped to - first, since PHP's native parser otherwise always reads slash-separated dates as month/day/year regardless of locale.
- Namespace
MMO\core\dates
| $dateTime = 'now' | DateTimeInterface | string | int | a unix timestamp, an existing date, 'now', an ISO-8601 duration ('P...'), or any string PHP's DateTime understands |
| $format = null | null | string | an explicit \DateTime::createFromFormat()-compatible format to try first |
| $immutable = null | null | bool | true/false to force DateTime/DateTimeImmutable; null keeps $dateTime's own type if it's already a DateTimeInterface, else defaults to mutable DateTime |
| $language = MMO\core\dates\LANGUAGE | string | used only to decide the / day/month disambiguation above |
| returns | DateTimeInterface |
dateTimeFromInterval
dates.php:246Apply an interval/modifier to a date, always returning a DateTimeImmutable.
- Namespace
MMO\core\dates
| $interval | DateInterval | string | can be : - a DateInterval instance, added to $dateTime - a date interval format (starting with 'P'), added to $dateTime (ISO-8601) - a date time modifier applied to $dateTime (PHP relative formats) |
| $dateTime = 'now' | DateTimeInterface | string | int | the base date (dateTime()) |
| returns | DateTimeImmutable | |
| throws | if $interval is a string that is neither an ISO-8601 duration nor a valid date/time modifier |
format
dates.php:269Format a date, then translate its month/day names to $lang (translateDate()).
- Namespace
MMO\core\dates- Todo
- replace by I18n module
| $format = 'l d F Y' | string | a \DateTime::format()-compatible format string |
| $date = 'now' | DateTimeInterface | string | int | dateTime() |
| $lang = MMO\core\dates\LANGUAGE | string | a locale code passed to translateDate() |
| returns |
Call graph
getDayNames
dates.php:130Get the 7 day names for $lang, in week order (Monday first).
- Namespace
MMO\core\dates- Todo
- replace by I18n module
| $short = false | bool | if true, return the abbreviated names |
| $lang = MMO\core\dates\LANGUAGE | string | a locale code (e.g. 'fr_FR') -- see the same caveat as getMonthNames() |
| returns | ||
| throws | if $lang has no translation table |
getFrenchBusinessDays
dates.php:447Same as getWorkingDays(), but automatically excludes French public holidays (getFrenchHolidays()) for every year the range spans (not just $startDate's year -- a range crossing into a new year must also exclude that year's holidays, New Year's Day included).
- Namespace
MMO\core\dates
| $startDate | DateTimeInterface | int | |
| $endDate | DateTimeInterface | int | |
| $alsace_moselle = false | bool | getFrenchHolidays() |
| returns | int | numbers of days |
Call graph
Uses (2)
getFrenchHolidays
dates.php:309Get every French public holiday of a given year, as ['Y-m-d' => 'name', ...], sorted by date. Cached per year (and per $alsace_moselle) for the rest of the request.
- Namespace
MMO\core\dates
| $year = null | null | int | null for the current year |
| $alsace_moselle = false | bool | if true, also include the two holidays specific to the Alsace-Moselle region (Good Friday, Saint Stephen's Day) |
| returns |
Call graph
Used by (2)
getMonthNames
dates.php:116Get the 12 month names for $lang, in calendar order (January first).
- Namespace
MMO\core\dates- Todo
- replace by I18n module
| $short = false | bool | if true, return the abbreviated names |
| $lang = MMO\core\dates\LANGUAGE | string | a locale code (e.g. 'fr_FR') -- NOTE: unlike translateDate(), English is NOT a built-in special case here; only locales present in MONTHS_i18n/MONTHS_SHORT_i18n work. |
| returns | ||
| throws | if $lang has no translation table |
getWorkingDays
dates.php:382Compute the number of working days (Mon-Fri, minus $holidays) between two dates, both inclusive.
- Namespace
MMO\core\dates
| $startDate | DateTimeInterface | int | |
| $endDate | DateTimeInterface | int | |
| $holidays = [] | array | a list of dates (anything \strtotime() accepts) to also exclude, in addition to weekends |
| returns | int |
Call graph
Used by (1)
isFrenchHoliday
dates.php:363Tells if a date is a French public holiday (getFrenchHolidays()).
- Namespace
MMO\core\dates
| $date = null | null | DateTimeInterface | null for today |
| $alsace_moselle = false | bool | getFrenchHolidays() |
| returns | bool |
Call graph
Uses (1)
isMDYFormat
dates.php:86- Namespace
MMO\core\dates
Call graph
Used by (1)
json
dates.php:281Format a date as ISO 8601 (c), for JSON output.
- Namespace
MMO\core\dates
| $date | mixed | dateTime() (already a DateTimeInterface is used as-is) |
| returns | string |
Call graph
Uses (1)
Used by (1)
nearestWeekDay
dates.php:475Get the closest week day (MON-FRI) to the given date: a Saturday snaps back to Friday, a Sunday snaps forward to Monday. When $allowMonthSpan is false and that snap would cross into the previous/next month, it snaps the OTHER direction instead (2 days) so the result always stays within the same month: a Saturday that's the 1st of the month jumps forward to Monday (the 3rd); a Sunday that's the last day of the month jumps backward to Friday.
- Namespace
MMO\core\dates
| $date | DateTimeInterface | |
| $allowMonthSpan = false | bool | if true, the result is allowed to land in the previous/next month |
| returns | DateTimeImmutable |
Call graph
Used by (1)
numberOfDays
dates.php:582Compute the total number of distinct days covered by a list of (possibly overlapping) day intervals, by merging them first (unionOfDayIntervals()) so an overlapping day is only counted once.
- Namespace
MMO\core\dates
| $ignoreTime = true | bool | unionOfDayIntervals() |
| ...$dates | DateTimeInterface | |
| returns | int |
Call graph
Uses (1)
RFC
dates.php:292Format a timestamp per RFC 1123/2822 (RFC_FORMAT), as used in HTTP dates and email headers.
- Namespace
MMO\core\dates
Call graph
Used by (1)
setTimezone
dates.php:145Set the default timezone for the rest of the request (date_default_timezone_set()).
- Namespace
MMO\core\dates
timezone
dates.php:136- Namespace
MMO\core\dates
| returns | DateTimeZone | the current default timezone (date_default_timezone_get()), as an object |
Call graph
Used by (1)
translateDate
dates.php:91- Namespace
MMO\core\dates
Call graph
Used by (1)
unionOfDayIntervals
dates.php:520Merge a list of (possibly overlapping or adjacent) day intervals into the smallest set of non-overlapping intervals that covers the same days. Intervals are passed flattened as consecutive [start, end] pairs.
- Namespace
MMO\core\dates
| $ignoreTime = true | bool | if true (default), every date's time-of-day is normalized before merging: a start date's time becomes 00:00:00, an end date's becomes 24:00:00 (i.e. midnight at the START of the FOLLOWING day) -- so a single-day interval like 2025-01-01..2025-01-01 is treated as the full day, and the returned end date is exclusive: it is one day AFTER the last day actually covered, not the last covered day itself. |
| ...$dates | DateTimeInterface | |
| returns | array | a flat list of merged, non-overlapping [start, end] pairs, in chronological order |
Call graph
Used by (1)
validate
dates.php:167Test if $value can be parsed by \DateTime::createFromFormat() using $format, AND round-trips back to exactly the same string when re-formatted -- i.e. it's not just loosely/partially parseable (e.g. PHP's parser is lenient about e.g. '2024-1-1' matching 'Y-m-d', but that wouldn't round-trip back to '2024-1-1').
- Namespace
MMO\core\dates
| $value | string | the string to validate |
| $format | string | a \DateTime::createFromFormat()-compatible format string. A leading !/| reset-flag (if any -- DATE_FORMATS for where this framework uses one) is stripped before the round-trip re-format: those flags are parse-only, \DateTime::format() has no notion of them and would otherwise emit them as a literal character, which could never match $value. |
| returns | bool |