achristodoulou/calendar

一个提供便捷访问日历功能的包。

v1.0.0 2015-11-26 22:42 UTC

This package is not auto-updated.

Last update: 2024-09-14 17:58:59 UTC


README

Latest Version on Packagist Build Status Software License

此包可用于任何与日历相关的查询。例如,您可以检查今天是否为特定日期,是否为公共假日,是否为工作日,是否为工作时间,是否为午餐时间,以及更多。

安装

通过Composer

$ composer require achristodoulou/calendar

用法

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');

输出

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

变更日志

有关最近更改的更多信息,请参阅变更日志

测试

$ composer test

贡献

有关详细信息,请参阅贡献指南

安全

如果您发现任何安全相关的问题,请通过电子邮件andreas22@gmail.com而不是使用问题跟踪器来报告。

致谢

  • [Andreas Christodoulou]

许可

MIT许可(MIT)。有关更多信息,请参阅许可文件