Git Product home page Git Product logo

lara-holidays's Introduction

LaraHolidays

This package is a helper package to work with workdays, weekends and holidays. It uses:

Installation

Via Composer

composer require tyler36/lara-holidays

Usage

This package extends Carbon to provide several useful features.

IsWorkDay

  • 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)

IsWeekendDay

  • 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)

IsHolidayDay

  • 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

GetPreviousWorkDay

  • 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)

GetNextWorkDay

  • This returns a date that is the next workday.
// Given 2022-08-05 (Friday)
Carbon::parse('2022-08-05')->getPreviousWorkDay()
// '2022-08-08' (Monday)

AdjustToPreviousWorkDayTest

  • Similar to "GetPreviousWorkDay", but also skips holidays. IE. Previous workday, not a weekend or holiday.

AdjustToNextWorkDayTest

  • Similar to "GetNextWorkDay", but also skips holidays. IE. Next workday, not a weekend or holiday.

Testing

phpunit

Contributing

Please see contributing.md for details and a todolist.

Security

If you discover any security related issues, please email [email protected] instead of using the issue tracker.

Credits

  • [Tyler36]

License

MIT. Please see the license file for more information.

lara-holidays's People

Contributors

tyler36 avatar

Watchers

 avatar

lara-holidays's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.