Overview
The BusinessDays plugin adds business day calculations to Atemporal. It allows you to work with business days while accounting for holidays and custom weekend configurations, making it perfect for scheduling, deadline calculations, and business logic.Installation
Using extend()
Using lazyLoad()
Configuration
setBusinessDaysConfig()
Configures holidays and weekend days for business day calculations.Instance Methods
isBusinessDay()
Checks if the current date is a business day (not a weekend or holiday).boolean - true if the date is a business day, false otherwise
Example:
isHoliday()
Checks if the current date is a configured holiday.boolean - true if the date is a holiday, false otherwise
Example:
isWeekend()
Checks if the current date falls on a weekend.boolean - true if the date is a weekend day, false otherwise
Example:
addBusinessDays()
Adds a specified number of business days to the current date.days- Number of business days to add (can be negative)
TemporalWrapper - New instance with business days added
Example:
subtractBusinessDays()
Subtracts a specified number of business days from the current date.days- Number of business days to subtract
TemporalWrapper - New instance with business days subtracted
Example:
nextBusinessDay()
Returns the next business day after the current date.TemporalWrapper - The next business day
Note: This always returns the next business day, even if the current day is already a business day.
Example:
Complete Example
Use Cases
Project Deadline Calculation
Service Level Agreement (SLA) Tracking
Regional Calendar Support
Notes
- Invalid dates always return
falsefor all check methods - Adding/subtracting 0 business days returns a clone of the current instance
- The configuration is global and affects all atemporal instances
- Holidays should be provided as date-only strings (YYYY-MM-DD) or Date objects
- Weekend days use ISO day numbering: 1 = Monday, 2 = Tuesday, …, 7 = Sunday
- The plugin intelligently skips weekends and holidays when calculating business days