Download the PHP package nickjbedford/calendar-timer without Composer
On this page you can find all versions of the php package nickjbedford/calendar-timer. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download nickjbedford/calendar-timer
More information about nickjbedford/calendar-timer
Files in nickjbedford/calendar-timer
Package calendar-timer
Short Description Provides classes to calculate past and future schedule dates based on a reference date.
License MIT
Homepage https://github.com/nickjbedford/calendar-timer
Informations about the package calendar-timer
YetAnother\CalendarTimer
Provides day, month and year-based calendar schedule calculation. For each type of timer, a reference date along with an interval is used to calculate past and future dates, from any date including now.
For example, to calculate a fortnightly schedule of dates from Wednesday 6th January 2021, you can use the following code:
Alternatively you can use the provided helper methods to create
calendar timer. These create instances of the DayTimer
, MonthTimer
or YearTimer
subclasses depending on the helper.
YetAnother\ScheduleFinder
The ScheduleFinder
class can be used to find the next or previous
date in a configuration for "available" workdays across a calendar year
while also specifying holiday dates to exclude.
Use Case Example
A business may only want to ship orders on Mondays, Wednesdays and Fridays but also prefer to only ship on the 5th, 15th and 25th days of each month. This class helps you discover the next most appropriate shipping date based on a reference date, allowing for an optional "earliest-date".
Example 1a
- Standard workdays are Monday to Friday.
- Today is the Monday 1st July 2024.
- A product doesn't need to be shipped until Thursday 11th July 2024.
- Preferred shipping days are Tuesdays and Fridays.
The ScheduleFinder::closest(date: '2024-07-11', earliestDate: '2024-07-01')
method will choose Tuesday 9th July 2024 as the preferred shipping day.
Example 1b
- It turns out tuesday 9th July is a public holiday.
- The next best workday is Monday 10th July 2024.