achristodoulou / calendar
A package that provides easy access to calendar functionality.
v1.0.0
2015-11-26 22:42 UTC
Requires (Dev)
- phpunit/phpunit: 4.8.*
This package is not auto-updated.
Last update: 2024-11-09 18:43:36 UTC
README
This package can be used for any calendar related queries. For example you can check if today is a specific date, if is public holidays, is working day, is working hours, is lunch time, is Christmas any many more.
Install
Via Composer
$ composer require achristodoulou/calendar
Usage
use \Achristodoulou\Calendar\Day; use \Achristodoulou\Calendar\ListOfDates; use \Achristodoulou\Calendar\TimeRange; use \Achristodoulou\Calendar\TwentyFourHourTime; use \Achristodoulou\Calendar\Today; $currentTime = new DateTime(); $workingHours = new TimeRange(new TwentyFourHourTime('08:00'), new TwentyFourHourTime('18:00')); $publicHolidays = new ListOfDates(); $publicHolidays->add(new DateTime('2015-01-18')); $annualLeave = new ListOfDates(); $annualLeave->add(new DateTime('2015-07-30')); $lunchTime = new TimeRange(new TwentyFourHourTime('12:00'), new TwentyFourHourTime('01:00')); $today = new Today($currentTime, $workingHours, $publicHolidays, $annualLeave, $lunchTime); echo "\nToday is Thursday: " . ($today->is(Day::THURSDAY) ? 'yes' : 'no'); echo "\nToday is Assumption Day: " . ($today->isAssumptionDay() ? 'yes' : 'no'); echo "\nToday is Public Holiday: " . ($today->isPublicHoliday() ? 'yes' : 'no'); echo "\nNow is After Working Hours: " . ($today->isAfterWorkingHour() ? 'yes' : 'no'); echo "\nToday I am on Annual Leave: " . ($today->isAnnualLeave() ? 'yes' : 'no'); echo "\nToday is Annunciation Day: " . ($today->isAnnunciationDay() ? 'yes' : 'no'); echo "\nToday is Christmas Day: " . ($today->isChristmas() ? 'yes' : 'no'); echo "\nToday is Epiphany Day: " . ($today->isEpiphanyDay() ? 'yes' : 'no'); echo "\nToday is Labour Day: " . ($today->isLabourDay() ? 'yes' : 'no'); echo "\nNow is Lunch Time: " . ($today->isLunchTime() ? 'yes' : 'no'); echo "\nToday is Midnight Of Working Day: " . ($today->isMidnightOfWorkingDay() ? 'yes' : 'no'); echo "\nToday is New Year Day: " . ($today->isNewYearDay() ? 'yes' : 'no'); echo "\nToday is Noon of Working Day: " . ($today->isNoonOfWorkingDay() ? 'yes' : 'no'); echo "\nToday is Weekend: " . ($today->isWeekend() ? 'yes' : 'no'); echo "\nToday is Working Day: " . ($today->isWorkingDay() ? 'yes' : 'no'); echo "\nNow is Working Hour: " . ($today->isWorkingHour() ? 'yes' : 'no');
Output:
Today is Thursday: yes
Today is Assumption Day: no
Today is Public Holiday: no�
Now is After Working Hours: yes
Today I am on Annual Leave: no
Today is Annunciation Day: no
Today is Christmas Day: no
Today is Epiphany Day: no
Today is Labour Day: no
Now is Lunch Time: no
Today is Midnight Of Working Day: no
Today is New Year Day: no
Today is Noon of Working Day: no
Today is Weekend: no
Today is Working Day: yes
Now is Working Hour: no
Change log
Please see CHANGELOG for more information what has changed recently.
Testing
$ composer test
Contributing
Please see CONTRIBUTING for details.
Security
If you discover any security related issues, please email andreas22@gmail.com instead of using the issue tracker.
Credits
- [Andreas Christodoulou]
License
The MIT License (MIT). Please see License File for more information.