This package is a helper package to work with workdays, weekends and holidays. It uses:
Via Composer
composer require tyler36/lara-holidays
This package extends Carbon to provide several useful features.
- This checks to see if the day is considered a 'work day'. Default is Monday => Friday
Carbon::parse('2022-08-01')->isWorkDay()
// -> True (Monday)
Carbon::parse('2022-08-06')->isWorkDay()
// -> False (Saturaday)
- This checks to see if the day is considered a 'weekend day'. Default is Saturday, Sunday
Carbon::parse('2022-08-01')->isWorkDay()
// -> False (Monday)
Carbon::parse('2022-08-06')->isWorkDay()
// -> True (Saturaday)
- This checks if the day is considered a holiday.
- Holidays are determined by the Yasumi package.
- Holidays are determined by locale which can be set in the config file. Default is 'Japan'
Carbon::parse('2022-01-01')->isHoliday()
// -> True
Carbon::parse('2022-12-25')->isHoliday()
// -> False (Default local is Japan)
LaraHolidays::setLocale('USA');
Carbon::parse('2022-12-25')->isHoliday()
// -> True
- This returns a date that is the first previous workday.
// Given '2022-08-06' (Saturaday)
Carbon::parse('2022-08-06')->getPreviousWorkDay()
// 2022-08-05 (Friday)
- This returns a date that is the next workday.
// Given 2022-08-05 (Friday)
Carbon::parse('2022-08-05')->getPreviousWorkDay()
// '2022-08-08' (Monday)
- Similar to "GetPreviousWorkDay", but also skips holidays. IE. Previous workday, not a weekend or holiday.
- Similar to "GetNextWorkDay", but also skips holidays. IE. Next workday, not a weekend or holiday.
phpunit
Please see contributing.md for details and a todolist.
If you discover any security related issues, please email author@email.com instead of using the issue tracker.
- [Tyler36]
MIT. Please see the license file for more information.