diff options
| author | Greg Roach <fisharebest@gmail.com> | 2014-09-14 16:30:03 +0100 |
|---|---|---|
| committer | Greg Roach <fisharebest@gmail.com> | 2014-09-14 16:30:03 +0100 |
| commit | 7bdf9f92e2997ea9e09ed9cd07b51c4be78e0738 (patch) | |
| tree | 057b01577fcd71793e59c40d9fcffa48199cd2ad /library/fisharebest/ext-calendar | |
| parent | 7bd92c16147b444f0f1d85cae368915c401a6f83 (diff) | |
| download | webtrees-7bdf9f92e2997ea9e09ed9cd07b51c4be78e0738.tar.gz webtrees-7bdf9f92e2997ea9e09ed9cd07b51c4be78e0738.tar.bz2 webtrees-7bdf9f92e2997ea9e09ed9cd07b51c4be78e0738.zip | |
Upgrade ext/calendar from 1.1.0 to 1.1.1
Diffstat (limited to 'library/fisharebest/ext-calendar')
6 files changed, 55 insertions, 32 deletions
diff --git a/library/fisharebest/ext-calendar/CHANGELOG.md b/library/fisharebest/ext-calendar/CHANGELOG.md index ae300d070b..13a7d6d2b9 100644 --- a/library/fisharebest/ext-calendar/CHANGELOG.md +++ b/library/fisharebest/ext-calendar/CHANGELOG.md @@ -1,6 +1,9 @@ CHANGE LOG ========== +## 1.1.1 (2014-09-14) + - Cannot inherit abstract classes in PHP 5.3.0 - 5.3.8. + ## 1.1.0 (2014-09-13) - Add support for Arabic (Hijri) and Persian (Jalali) calendars. - Convert logic to lookup tables for better performance. diff --git a/library/fisharebest/ext-calendar/README.md b/library/fisharebest/ext-calendar/README.md index 1f8225fb21..ef6cc00849 100644 --- a/library/fisharebest/ext-calendar/README.md +++ b/library/fisharebest/ext-calendar/README.md @@ -56,7 +56,7 @@ If you want to create the “shim” functions, you must tell the package to cre \Fisharebest\ExtCalendar\Shim::create(); ``` -Now you can use the PHP functions, whether the ext/calendar is installed or not: +Now you can use the PHP functions, whether `ext/calendar` is installed or not: ``` php print_r(cal_info(CAL_GREGORIAN)); diff --git a/library/fisharebest/ext-calendar/src/Calendar.php b/library/fisharebest/ext-calendar/src/Calendar.php index 2f48e8b581..6884ac4aa6 100644 --- a/library/fisharebest/ext-calendar/src/Calendar.php +++ b/library/fisharebest/ext-calendar/src/Calendar.php @@ -45,13 +45,6 @@ abstract class Calendar { const MAX_DAYS_IN_MONTH = 31; /** - * The concrete class needs to provide the implementation. - * - * @return string[] - */ - protected abstract function monthNames(); - - /** * English names for the days of the week. * * @return string[] @@ -74,24 +67,6 @@ abstract class Calendar { } /** - * The concrete class needs to provide the implementation. - * - * @param $jd - */ - public abstract function jdToYmd($jd); - - /** - * The concrete class needs to provide the implementation. - * - * @param int $year - * @param int $month - * @param int $day - * - * @return int - */ - public abstract function ymdToJd($year, $month, $day); - - /** * Convert a Julian Day number into a calendar date. * * @param $jd diff --git a/library/fisharebest/ext-calendar/src/CalendarInterface.php b/library/fisharebest/ext-calendar/src/CalendarInterface.php index 3373b03fac..ca03634190 100644 --- a/library/fisharebest/ext-calendar/src/CalendarInterface.php +++ b/library/fisharebest/ext-calendar/src/CalendarInterface.php @@ -21,9 +21,50 @@ namespace Fisharebest\ExtCalendar; * along with this program. If not, see <http://www.gnu.org/licenses/>. */ interface CalendarInterface { - public function daysInMonth($year, $month); - public function dayOfWeek($jd); + /** + * Convert a Julian day number into a year/month/day. + * + * @param $jd + * + * @return int[] + */ public function jdToYmd($jd); - public function leapYear($year); + + /** + * Convert a year/month/day to a Julian day number. + * + * @param int $year + * @param int $month + * @param int $day + * + * @return int + */ public function ymdToJd($year, $month, $day); + + /** + * Determine whether or not a given year is a leap-year. + * + * @param int $year + * + * @return bool + */ + public function leapYear($year); + + /** + * Determine the number of days in a specified month, allowing for leap years, etc. + * + * @param int $year + * @param int $month + * + * @return int + */ + public function daysInMonth($year, $month); + + /** + * Provide a list of month names, as required by PHP::cal_info() + * + * @return string[] + */ + public function monthNames(); + } diff --git a/library/fisharebest/ext-calendar/src/FrenchCalendar.php b/library/fisharebest/ext-calendar/src/FrenchCalendar.php index 2f30a192ea..18ead98495 100644 --- a/library/fisharebest/ext-calendar/src/FrenchCalendar.php +++ b/library/fisharebest/ext-calendar/src/FrenchCalendar.php @@ -47,6 +47,10 @@ class FrenchCalendar extends Calendar implements CalendarInterface { /** * Determine whether a year is a leap year. * + * Leap years were based on astronomical observations. Only years 3, 7 and 11 + * were ever observed. Moves to a gregorian-like (fixed) system were proposed + * but never implemented. + * * @param int $year * @return bool */ diff --git a/library/fisharebest/ext-calendar/src/PersianCalendar.php b/library/fisharebest/ext-calendar/src/PersianCalendar.php index 7d22e7bc33..85f0f44af0 100644 --- a/library/fisharebest/ext-calendar/src/PersianCalendar.php +++ b/library/fisharebest/ext-calendar/src/PersianCalendar.php @@ -72,7 +72,7 @@ class PersianCalendar extends Calendar implements CalendarInterface { * @return int[]; */ public function jdToYmd($jd) { - $depoch = $jd - self::YMDtoJD(475, 1, 1); + $depoch = $jd - $this->ymdToJd(475, 1, 1); $cycle = (int)($depoch / 1029983); $cyear = $depoch % 1029983; if ($cyear == 1029982) { @@ -87,9 +87,9 @@ class PersianCalendar extends Calendar implements CalendarInterface { if ($year <= 0) { $year--; } - $yday = ($jd - self::YMDtoJD($year, 1, 1)) + 1; + $yday = ($jd - $this->ymdToJd($year, 1, 1)) + 1; $month = ($yday <= 186) ? ceil($yday / 31) : ceil(($yday - 6) / 30); - $day = ($jd - self::YMDtoJD($year, $month, 1)) + 1; + $day = ($jd - $this->ymdToJd($year, $month, 1)) + 1; return array($year, (int)$month, (int)$day); } |
