WeeklyCalendar
in package
FinalYes
Repeating weekly schedule used by shipment and dispatch calendars.
Table of Contents
Properties
- $moments : array<int, WeeklyCalendarMoment>
- $rejectInvalidLocalTimes : bool
- $windows : array<int, WeeklyCalendarWindow>
Methods
- __construct() : mixed
- Create one weekly calendar from moments and windows.
- fromMap() : self
- Build one weekly calendar from a weekday => list of moment/window expressions map.
- merge() : self
- Merge multiple weekly calendars into one deduplicated calendar.
- nextTime() : int
- Return the first bucket index at or after the given time that matches this weekly schedule.
- assertValidLocalTime() : void
- earlierDateTime() : DateTimeImmutable
- expandDaySelector() : array<int, int>
- isoFromZeroBased() : int
- normalizeDayToken() : int
- parseEntry() : WeeklyCalendarMoment|WeeklyCalendarWindow
- startOfIsoWeek() : DateTimeImmutable
Properties
$moments read-only
public
array<int, WeeklyCalendarMoment>
$moments
$rejectInvalidLocalTimes read-only
public
bool
$rejectInvalidLocalTimes
= false
$windows read-only
public
array<int, WeeklyCalendarWindow>
$windows
Methods
__construct()
Create one weekly calendar from moments and windows.
public
__construct(array<int, WeeklyCalendarMoment|WeeklyCalendarWindow> $entries[, bool $rejectInvalidLocalTimes = false ]) : mixed
Parameters
- $entries : array<int, WeeklyCalendarMoment|WeeklyCalendarWindow>
- $rejectInvalidLocalTimes : bool = false
fromMap()
Build one weekly calendar from a weekday => list of moment/window expressions map.
public
static fromMap(array<int|string, string|array<int, string>> $map[, bool $rejectInvalidLocalTimes = false ]) : self
Example: ['mon-thu,fri' => ['10:00', '13:00-16:00'], '6,7' => ['09:00']]
Parameters
- $map : array<int|string, string|array<int, string>>
- $rejectInvalidLocalTimes : bool = false
Return values
selfmerge()
Merge multiple weekly calendars into one deduplicated calendar.
public
static merge(self ...$calendars) : self
Parameters
- $calendars : self
Return values
selfnextTime()
Return the first bucket index at or after the given time that matches this weekly schedule.
public
nextTime(TimeAxis $axis, int $earliestTime) : int
Parameters
- $axis : TimeAxis
- $earliestTime : int
Return values
intassertValidLocalTime()
private
assertValidLocalTime(WeeklyCalendarMoment $moment, DateTimeImmutable $candidate) : void
Parameters
- $moment : WeeklyCalendarMoment
- $candidate : DateTimeImmutable
earlierDateTime()
private
earlierDateTime(DateTimeImmutable|null $current, DateTimeImmutable $candidate) : DateTimeImmutable
Parameters
- $current : DateTimeImmutable|null
- $candidate : DateTimeImmutable
Return values
DateTimeImmutableexpandDaySelector()
private
static expandDaySelector(int|string $selector) : array<int, int>
Parameters
- $selector : int|string
Return values
array<int, int>isoFromZeroBased()
private
static isoFromZeroBased(int $index) : int
Parameters
- $index : int
Return values
intnormalizeDayToken()
private
static normalizeDayToken(string $token) : int
Parameters
- $token : string
Return values
intparseEntry()
private
static parseEntry(int|string $weekday, string $expression) : WeeklyCalendarMoment|WeeklyCalendarWindow
Parameters
- $weekday : int|string
- $expression : string
Return values
WeeklyCalendarMoment|WeeklyCalendarWindowstartOfIsoWeek()
private
startOfIsoWeek(DateTimeImmutable $time) : DateTimeImmutable
Parameters
- $time : DateTimeImmutable