2017 © Pedro Peláez
 

library ext-calendar

Implementation of the Arabic (Hijri), French, Gregorian, Jewish, Julian and Persian (Jalali) calendars. Also provides a replacement for the PHP ext/calendar extension.

image

fisharebest/ext-calendar

Implementation of the Arabic (Hijri), French, Gregorian, Jewish, Julian and Persian (Jalali) calendars. Also provides a replacement for the PHP ext/calendar extension.

  • Wednesday, February 21, 2018
  • by fisharebest
  • Repository
  • 1 Watchers
  • 16 Stars
  • 40,527 Installations
  • PHP
  • 6 Dependents
  • 0 Suggesters
  • 4 Forks
  • 1 Open issues
  • 19 Versions
  • 5 % Grown

The README.md

Build Status Coverage Status SensioLabsInsight Scrutinizer Code Quality StyleCI Code Climate, (*1)

PHP calendar functions

This package provides an implementation of the Arabic (Hijri), French Republican, Gregorian, Julian, Jewish and Persian (Jalali) calendars, plus a replacement for PHP‘s ext/calendar extension. It allows you to use the following PHP functions on servers that do not have the ext/calendar extension installed (such as HHVM)., (*2)

How to use it

Add the package as a dependency in your composer.json file:, (*3)

``` javascript require { "fisharebest/ext-calendar": "~2.5" }, (*4)


Now you can use the PHP functions, whether `ext/calendar` is installed or not. Since version 2.2, it is no longer necessary to initialise these using `Shim::create()`. ``` php require 'vendor/autoload.php'; print_r(cal_info(CAL_GREGORIAN)); // Works in HHVM, or if ext-calendar is not installed

Alternatively, just use the calendar classes directly., (*5)

``` php require 'vendor/autoload.php';, (*6)

// Create calendars $calendar = new Fisharebest\ExtCalendar\ArabicCalendar; $calendar = new Fisharebest\ExtCalendar\FrenchCalendar; $calendar = new Fisharebest\ExtCalendar\GregorianCalendar; $calendar = new Fisharebest\ExtCalendar\JewishCalendar; $calendar = new Fisharebest\ExtCalendar\JulianCalendar; $calendar = new Fisharebest\ExtCalendar\PersianCalendar;, (*7)

// Date conversions $julian_day = $calendar->ymdToJd($year, $month, $day); list($year, $month, $day) = $calendar->jdToYmd($julian_day);, (*8)

// Information about days, weeks and months $is_leap_year = $calendar->isLeapYear($year); $days_in_month = $calendar->daysInMonth($year, $month); $months_in_year = $calendar->monthsInYear(); // Not all calendars have 12 $months_in_year = $calendar->monthsInYear($year); // In a specific year $days_in_week = $calendar->daysInWeek(); // Not all calendars have 7, (*9)

// Which dates are valid for this calendar? $jd = $calendar->jdStart(); $jd = $calendar->jdEnd();, (*10)

// Miscellaneous utilities $jewish = new JewishCalendar; $jewish->numberToHebrewNumerals(5781, false); // "תשפ״א" $jewish->numberToHebrewNumerals(5781, true); // "ה׳תשפ״א" ```, (*11)

Known restrictions and limitations

When faced with invalid inputs, the shim functions trigger E_USER_WARNING instead of E_WARNING. The text of the error messages is the same., (*12)

The functions easterdate() and jdtounixtime() use PHP‘s timezone, instead of the operating system‘s timezone. These may be different., (*13)

Compatibility with different versions of PHP

The following PHP bugs are emulated, according to the version of PHP being used. Thus the package always provides the same behaviour as the native ext/calendar extension., (*14)

  • #54254 Jewish month "Adar" - fixed in PHP 5.5., (*15)

  • #67960 Constants CAL_DOW_SHORT and CAL_DOW_LONG - found and fixed by this project - fixed in PHP 5.5.21 and 5.6.5., (*16)

  • #67976 Wrong value in cal_days_in_month() for French calendar - found by this project., (*17)

Development and contributions

Due to the known restrictions above, you may need to run unit tests using TZ=UTC phpunit., (*18)

Pull requests are welcome. Please ensure you include unit-tests where applicable., (*19)

History

These functions were originally written for the webtrees project. As part of a refactoring process, they were extracted to a standalone library, given version numbers, unit tests, etc., (*20)

Future plans

  • Support alternate leap-year schemes for the French calendar (true equinox, Romme, 128-year cycle) as well as the 4-year cycle.
  • Support other calendars, such as Ethiopian, Hindu, Chinese, etc.

The Versions

21/02 2018

dev-master

9999999-dev https://github.com/fisharebest/ext-calendar

Implementation of the Arabic (Hijri), French, Gregorian, Jewish, Julian and Persian (Jalali) calendars. Also provides a replacement for the PHP ext/calendar extension.

  Sources   Download

GPL-3.0+

The Requires

  • php >=5.3.0

 

The Development Requires

by Greg Roach

calendar french jalali persian arabic shamsi gregorian ext-calendar julian jewish hebrew julian day julian day number hijri

16/01 2018

2.4.0

2.4.0.0 https://github.com/fisharebest/ext-calendar

Implementation of the Arabic (Hijri), French, Gregorian, Jewish, Julian and Persian (Jalali) calendars. Also provides a replacement for the PHP ext/calendar extension.

  Sources   Download

GPL-3.0+

The Requires

  • php >=5.3.0

 

The Development Requires

by Greg Roach

calendar french jalali persian arabic shamsi gregorian ext-calendar julian jewish hebrew julian day julian day number hijri

16/01 2018

dev-develop

dev-develop https://github.com/fisharebest/ext-calendar

Implementation of the Arabic (Hijri), French, Gregorian, Jewish, Julian and Persian (Jalali) calendars. Also provides a replacement for the PHP ext/calendar extension.

  Sources   Download

GPL-3.0+

The Requires

  • php >=5.3.0

 

The Development Requires

by Greg Roach

calendar french jalali persian arabic shamsi gregorian ext-calendar julian jewish hebrew julian day julian day number hijri

16/01 2018

2.3.1

2.3.1.0 https://github.com/fisharebest/ext-calendar

Implementation of the Arabic (Hijri), French, Gregorian, Jewish, Julian and Persian (Jalali) calendars. Also provides a replacement for the PHP ext/calendar extension.

  Sources   Download

GPL-3.0+

The Requires

  • php >=5.3.0

 

The Development Requires

by Greg Roach

calendar french jalali persian arabic shamsi gregorian ext-calendar julian jewish hebrew julian day julian day number hijri

07/05 2017

2.3.0

2.3.0.0 https://github.com/fisharebest/ext-calendar

Implementation of the Arabic (Hijri), French, Gregorian, Jewish, Julian and Persian (Jalali) calendars. Also provides a replacement for the PHP ext/calendar extension.

  Sources   Download

GPL-3.0+

The Requires

  • php >=5.3.0

 

The Development Requires

by Greg Roach

calendar french jalali persian arabic shamsi gregorian ext-calendar julian jewish hebrew julian day julian day number hijri

11/12 2015

2.2.1

2.2.1.0 https://github.com/fisharebest/ext-calendar

Implementation of the Arabic (Hijri), French, Gregorian, Jewish, Julian and Persian (Jalali) calendars. Also provides a replacement for the PHP ext/calendar extension.

  Sources   Download

GPL-3.0+

The Requires

  • php >=5.3.0

 

The Development Requires

by Greg Roach

calendar french jalali persian arabic shamsi gregorian ext-calendar julian jewish hebrew julian day julian day number hijri

30/11 2015

2.2.0

2.2.0.0 https://github.com/fisharebest/ext-calendar

Implementation of the Arabic (Hijri), French, Gregorian, Jewish, Julian and Persian (Jalali) calendars. Also provides a replacement for the PHP ext/calendar extension.

  Sources   Download

GPL-3.0+

The Requires

  • php >=5.3.0

 

The Development Requires

by Greg Roach

calendar french jalali persian arabic shamsi gregorian ext-calendar julian jewish hebrew julian day julian day number hijri

21/09 2015

2.1.1

2.1.1.0 https://github.com/fisharebest/ext-calendar

Implementation of the Arabic (Hijri), French, Gregorian, Jewish, Julian and Persian (Jalali) calendars. Optional PHP shims for servers without the ext/calendar extension.

  Sources   Download

GPL-3.0+

The Requires

  • php >=5.3.0

 

The Development Requires

by Greg Roach

calendar french jalali persian arabic shamsi gregorian ext-calendar julian jewish hebrew julian day julian day number hijri

02/04 2015

2.1.0

2.1.0.0 https://github.com/fisharebest/ext-calendar

Implementation of the Arabic (Hijri), French, Gregorian, Jewish, Julian and Persian (Jalali) calendars. Optional PHP shims for servers without the ext/calendar extension.

  Sources   Download

GPL-3.0+

The Requires

  • php >=5.3.0

 

The Development Requires

by Greg Roach

calendar french jalali persian arabic shamsi gregorian ext-calendar julian jewish hebrew julian day julian day number hijri

01/04 2015

2.0.0

2.0.0.0 https://github.com/fisharebest/ext-calendar

Implementation of the Arabic (Hijri), French, Gregorian, Jewish, Julian and Persian (Jalali) calendars. Optional PHP shims for servers without the ext/calendar extension.

  Sources   Download

GPL-3.0+

The Requires

  • php >=5.3.0

 

The Development Requires

by Greg Roach

calendar french jalali persian arabic shamsi gregorian ext-calendar julian jewish hebrew julian day julian day number hijri

31/10 2014

1.3.0

1.3.0.0 https://github.com/fisharebest/ext-calendar

Implementation of the Arabic (Hijri), French, Gregorian, Jewish, Julian and Persian (Jalali) calendars. Optional PHP shims for servers without the ext/calendar extension.

  Sources   Download

GPL-3.0+

The Requires

  • php >=5.3.0

 

The Development Requires

by Greg Roach

calendar french jalali persian arabic shamsi gregorian ext-calendar julian jewish hebrew julian day julian day number hijri

27/09 2014

1.2.0

1.2.0.0 https://github.com/fisharebest/ext-calendar

Implementation of the Arabic (Hijri), French, Gregorian, Jewish, Julian and Persian (Jalali) calendars. PHP shims for the ext/calendar extension.

  Sources   Download

GPL-3.0+

The Requires

  • php >=5.3.0

 

The Development Requires

by Greg Roach

calendar french jalali persian arabic shamsi gregorian ext-calendar julian jewish hebrew julian day julian day number hijri

16/09 2014

1.1.2

1.1.2.0 https://github.com/fisharebest/ext-calendar

Implementation of various calendars, plus PHP shims for the ext/calendar extension

  Sources   Download

GPL-3.0+

The Requires

  • php >=5.3.0

 

The Development Requires

by Greg Roach

calendar french gregorian ext-calendar julian jewish hebrew julian day julian day number

14/09 2014

1.1.1

1.1.1.0 https://github.com/fisharebest/ext-calendar

Implementation of various calendars, plus PHP shims for the ext/calendar extension

  Sources   Download

GPL-3.0+

The Requires

  • php >=5.3.0

 

The Development Requires

by Greg Roach

calendar french gregorian ext-calendar julian jewish hebrew julian day julian day number

13/09 2014

1.1.0

1.1.0.0 https://github.com/fisharebest/ext-calendar

Implementation of various calendars, plus PHP shims for the ext/calendar extension

  Sources   Download

GPL-3.0+

The Requires

  • php >=5.3.0

 

The Development Requires

by Greg Roach

calendar french gregorian ext-calendar julian jewish hebrew julian day julian day number

12/09 2014

1.0.3

1.0.3.0 https://github.com/fisharebest/ext-calendar

Implementation of various calendars, plus PHP shims for the ext/calendar extension

  Sources   Download

GPL-3.0+

The Requires

  • php >=5.3.0

 

The Development Requires

by Greg Roach

calendar french gregorian ext-calendar julian jewish hebrew julian day julian day number

11/09 2014

1.0.2

1.0.2.0 https://github.com/fisharebest/ext-calendar

Implementation of various calendars, plus PHP shims for the ext/calendar extension

  Sources   Download

GPL-3.0+

The Requires

  • php >=5.3.0

 

The Development Requires

by Greg Roach

calendar french gregorian ext-calendar julian jewish hebrew julian day julian day number

11/09 2014

1.0.1

1.0.1.0 https://github.com/fisharebest/ext-calendar

Implementation of various calendars, plus PHP shims for the ext/calendar extension

  Sources   Download

GPL-3.0+

The Requires

  • php >=5.3.0

 

The Development Requires

by Greg Roach

calendar french gregorian ext-calendar julian jewish hebrew julian day julian day number

10/09 2014

1.0.0

1.0.0.0 https://github.com/fisharebest/ext-calendar

PHP shim for the ext/calendar extension

  Sources   Download

GPL-3.0+

The Requires

  • php >=5.3.0

 

The Development Requires

by Greg Roach

calendar french gregorian ext-calendar julian jewish hebrew julian day julian day number