项目作者: pizar

项目描述 :
Carbon Support for IT Holidays
高级语言: PHP
项目地址: git://github.com/pizar/carbon-it-holidays.git
创建时间: 2019-01-09T18:12:05Z
项目社区:https://github.com/pizar/carbon-it-holidays

开源协议:MIT License

下载


Carbon Support for IT Holidays

This extends Carbon and adds support for several IT holidays.

I start from this repo: https://github.com/geoffreyrose/us-holidays and i customize for italian calendar

Supported Holidays

  • New Years Day
  • Epiphany
  • Easter
  • Easter Monday
  • Liberation Day
  • Labour Day
  • Republic day
  • Assumption of Mary
  • All Saints’ Day
  • Immaculate Conception Day
  • Christmas Day
  • St. Stephen’s Day

Requirements

Usage

With Composer

  1. $ composer require pizar/carbon-it-holidays
  1. <?php
  2. require 'vendor/autoload.php';
  3. use ITHolidays\Carbon;

Without Composer

  1. <?php
  2. require 'path/to/nesbot/Carbon.php';
  3. require 'path/to/pizar/Carbon.php';
  4. use ITHolidays\Carbon;

Check if date is holiday. Returns boolean

  1. $carbon = new Carbon();
  2. $carbon = Carbon::create(2018, 12, 25);
  3. $carbon->isHoliday(); // bool (true)

Get name if date is holiday. Returns string or false

  1. $carbon = new Carbon();
  2. $carbon = Carbon::create(2018, 12, 31);
  3. $carbon->getHolidayName(); // New Year's Eve

Get date for a specific holiday. Returns string

  1. $carbon = new Carbon();
  2. $carbon = Carbon::create(2018, 1, 1);
  3. $carbon->getNewYearsDayHoliday(); // 2019-01-01 00:00:00
  4. $carbon->getEpiphanyHoliday(); // 2019-01-06 00:00:00
  5. $carbon->getEasterMondayHoliday(); // 2019-04-22 00:00:00
  6. $carbon->getLiberationDayHoliday(); // 2018-04-25 00:00:00
  7. $carbon->getLabourDayHoliday(); // 2018-05-01 00:00:00
  8. $carbon->getRepublicDayHoliday(); // 2018-06-02 00:00:00
  9. $carbon->getAssumptionOfMaryHoliday(); // 2018-08-15 00:00:00
  10. $carbon->getFerragosto(); // 2018-08-15 00:00:00
  11. $carbon->getAllSaintsDayHoliday(); // 2018-11-01 00:00:00
  12. $carbon->getImmaculateConceptionDayHoliday(); // 2018-12-08 00:00:00
  13. $carbon->getChristmasDayHoliday(); // 2018-12-25 00:00:00
  14. $carbon->getStStephenDayHoliday(); // 2018-12-26 00:00:00

see https://github.com/geoffreyrose/us-holidays for other examples too