1a25f0a04SGreg Roach<?php 2dd04c183SGreg Roachnamespace Fisharebest\Webtrees; 3a25f0a04SGreg Roach 4a25f0a04SGreg Roach/** 5a25f0a04SGreg Roach * webtrees: online genealogy 6a25f0a04SGreg Roach * Copyright (C) 2015 webtrees development team 7a25f0a04SGreg Roach * This program is free software: you can redistribute it and/or modify 8a25f0a04SGreg Roach * it under the terms of the GNU General Public License as published by 9a25f0a04SGreg Roach * the Free Software Foundation, either version 3 of the License, or 10a25f0a04SGreg Roach * (at your option) any later version. 11a25f0a04SGreg Roach * This program is distributed in the hope that it will be useful, 12a25f0a04SGreg Roach * but WITHOUT ANY WARRANTY; without even the implied warranty of 13a25f0a04SGreg Roach * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14a25f0a04SGreg Roach * GNU General Public License for more details. 15a25f0a04SGreg Roach * You should have received a copy of the GNU General Public License 16a25f0a04SGreg Roach * along with this program. If not, see <http://www.gnu.org/licenses/>. 17a25f0a04SGreg Roach */ 18a25f0a04SGreg Roach 19a25f0a04SGreg Roachuse Fisharebest\ExtCalendar\JewishCalendar; 20a25f0a04SGreg Roach 21a25f0a04SGreg Roach/** 22a25f0a04SGreg Roach * Class JewishDate - Definitions for the Jewish calendar 23a25f0a04SGreg Roach */ 24a25f0a04SGreg Roachclass JewishDate extends CalendarDate { 25a25f0a04SGreg Roach /** {@inheritdoc} */ 26a25f0a04SGreg Roach public static $MONTH_ABBREV = array('' => 0, 'TSH' => 1, 'CSH' => 2, 'KSL' => 3, 'TVT' => 4, 'SHV' => 5, 'ADR' => 6, 'ADS' => 7, 'NSN' => 8, 'IYR' => 9, 'SVN' => 10, 'TMZ' => 11, 'AAV' => 12, 'ELL' => 13); 27a25f0a04SGreg Roach 28a25f0a04SGreg Roach /** {@inheritdoc} */ 29a25f0a04SGreg Roach public function __construct($date) { 30a25f0a04SGreg Roach $this->calendar = new JewishCalendar; 31a25f0a04SGreg Roach parent::__construct($date); 32a25f0a04SGreg Roach } 33a25f0a04SGreg Roach 34a25f0a04SGreg Roach /** {@inheritdoc} */ 35*17920f94SGreg Roach protected function formatDay() { 36*17920f94SGreg Roach if (WT_LOCALE === 'he' || WT_LOCALE === 'yi') { 37*17920f94SGreg Roach return $this->calendar->numberToHebrewNumerals($this->d, true); 38a25f0a04SGreg Roach } else { 39a25f0a04SGreg Roach return $this->d; 40a25f0a04SGreg Roach } 41a25f0a04SGreg Roach } 42a25f0a04SGreg Roach 43a25f0a04SGreg Roach /** {@inheritdoc} */ 44*17920f94SGreg Roach protected function formatShortYear() { 45*17920f94SGreg Roach if (WT_LOCALE === 'he' || WT_LOCALE === 'yi') { 46*17920f94SGreg Roach return $this->calendar->numberToHebrewNumerals($this->y, false); 47a25f0a04SGreg Roach } else { 48a25f0a04SGreg Roach return $this->y; 49a25f0a04SGreg Roach } 50a25f0a04SGreg Roach } 51a25f0a04SGreg Roach 52a25f0a04SGreg Roach /** {@inheritdoc} */ 53*17920f94SGreg Roach protected function formatLongYear() { 54*17920f94SGreg Roach if (WT_LOCALE === 'he' || WT_LOCALE === 'yi') { 55*17920f94SGreg Roach return $this->calendar->numberToHebrewNumerals($this->y, true); 56a25f0a04SGreg Roach } else { 57a25f0a04SGreg Roach return $this->y; 58a25f0a04SGreg Roach } 59a25f0a04SGreg Roach } 60a25f0a04SGreg Roach 61a25f0a04SGreg Roach /** {@inheritdoc} */ 62a25f0a04SGreg Roach public static function monthNameNominativeCase($month_number, $leap_year) { 63a25f0a04SGreg Roach static $translated_month_names; 64a25f0a04SGreg Roach 65a25f0a04SGreg Roach if ($translated_month_names === null) { 66a25f0a04SGreg Roach $translated_month_names = array( 67a25f0a04SGreg Roach 0 => '', 68764a01d9SGreg Roach 1 => /* I18N: a month in the Jewish calendar */ I18N::translateContext('NOMINATIVE', 'Tishrei'), 69764a01d9SGreg Roach 2 => /* I18N: a month in the Jewish calendar */ I18N::translateContext('NOMINATIVE', 'Heshvan'), 70764a01d9SGreg Roach 3 => /* I18N: a month in the Jewish calendar */ I18N::translateContext('NOMINATIVE', 'Kislev'), 71764a01d9SGreg Roach 4 => /* I18N: a month in the Jewish calendar */ I18N::translateContext('NOMINATIVE', 'Tevet'), 72764a01d9SGreg Roach 5 => /* I18N: a month in the Jewish calendar */ I18N::translateContext('NOMINATIVE', 'Shevat'), 73764a01d9SGreg Roach 6 => /* I18N: a month in the Jewish calendar */ I18N::translateContext('NOMINATIVE', 'Adar I'), 74764a01d9SGreg Roach 7 => /* I18N: a month in the Jewish calendar */ I18N::translateContext('NOMINATIVE', 'Adar'), 75764a01d9SGreg Roach -7 => /* I18N: a month in the Jewish calendar */ I18N::translateContext('NOMINATIVE', 'Adar II'), 76764a01d9SGreg Roach 8 => /* I18N: a month in the Jewish calendar */ I18N::translateContext('NOMINATIVE', 'Nissan'), 77764a01d9SGreg Roach 9 => /* I18N: a month in the Jewish calendar */ I18N::translateContext('NOMINATIVE', 'Iyar'), 78764a01d9SGreg Roach 10 => /* I18N: a month in the Jewish calendar */ I18N::translateContext('NOMINATIVE', 'Sivan'), 79764a01d9SGreg Roach 11 => /* I18N: a month in the Jewish calendar */ I18N::translateContext('NOMINATIVE', 'Tamuz'), 80764a01d9SGreg Roach 12 => /* I18N: a month in the Jewish calendar */ I18N::translateContext('NOMINATIVE', 'Av'), 81764a01d9SGreg Roach 13 => /* I18N: a month in the Jewish calendar */ I18N::translateContext('NOMINATIVE', 'Elul'), 82a25f0a04SGreg Roach ); 83a25f0a04SGreg Roach } 84a25f0a04SGreg Roach 85a25f0a04SGreg Roach if ($month_number === 7 && $leap_year) { 86a25f0a04SGreg Roach return $translated_month_names[-7]; 87a25f0a04SGreg Roach } else { 88a25f0a04SGreg Roach return $translated_month_names[$month_number]; 89a25f0a04SGreg Roach } 90a25f0a04SGreg Roach } 91a25f0a04SGreg Roach 92a25f0a04SGreg Roach /** {@inheritdoc} */ 93*17920f94SGreg Roach protected function monthNameGenitiveCase($month_number, $leap_year) { 94a25f0a04SGreg Roach static $translated_month_names; 95a25f0a04SGreg Roach 96a25f0a04SGreg Roach if ($translated_month_names === null) { 97a25f0a04SGreg Roach $translated_month_names = array( 98a25f0a04SGreg Roach 0 => '', 99764a01d9SGreg Roach 1 => /* I18N: a month in the Jewish calendar */ I18N::translateContext('GENITIVE', 'Tishrei'), 100764a01d9SGreg Roach 2 => /* I18N: a month in the Jewish calendar */ I18N::translateContext('GENITIVE', 'Heshvan'), 101764a01d9SGreg Roach 3 => /* I18N: a month in the Jewish calendar */ I18N::translateContext('GENITIVE', 'Kislev'), 102764a01d9SGreg Roach 4 => /* I18N: a month in the Jewish calendar */ I18N::translateContext('GENITIVE', 'Tevet'), 103764a01d9SGreg Roach 5 => /* I18N: a month in the Jewish calendar */ I18N::translateContext('GENITIVE', 'Shevat'), 104764a01d9SGreg Roach 6 => /* I18N: a month in the Jewish calendar */ I18N::translateContext('GENITIVE', 'Adar I'), 105764a01d9SGreg Roach 7 => /* I18N: a month in the Jewish calendar */ I18N::translateContext('GENITIVE', 'Adar'), 106764a01d9SGreg Roach -7 => /* I18N: a month in the Jewish calendar */ I18N::translateContext('GENITIVE', 'Adar II'), 107764a01d9SGreg Roach 8 => /* I18N: a month in the Jewish calendar */ I18N::translateContext('GENITIVE', 'Nissan'), 108764a01d9SGreg Roach 9 => /* I18N: a month in the Jewish calendar */ I18N::translateContext('GENITIVE', 'Iyar'), 109764a01d9SGreg Roach 10 => /* I18N: a month in the Jewish calendar */ I18N::translateContext('GENITIVE', 'Sivan'), 110764a01d9SGreg Roach 11 => /* I18N: a month in the Jewish calendar */ I18N::translateContext('GENITIVE', 'Tamuz'), 111764a01d9SGreg Roach 12 => /* I18N: a month in the Jewish calendar */ I18N::translateContext('GENITIVE', 'Av'), 112764a01d9SGreg Roach 13 => /* I18N: a month in the Jewish calendar */ I18N::translateContext('GENITIVE', 'Elul'), 113a25f0a04SGreg Roach ); 114a25f0a04SGreg Roach } 115a25f0a04SGreg Roach 116a25f0a04SGreg Roach if ($month_number === 7 && $leap_year) { 117a25f0a04SGreg Roach return $translated_month_names[-7]; 118a25f0a04SGreg Roach } else { 119a25f0a04SGreg Roach return $translated_month_names[$month_number]; 120a25f0a04SGreg Roach } 121a25f0a04SGreg Roach } 122a25f0a04SGreg Roach 123a25f0a04SGreg Roach /** {@inheritdoc} */ 124*17920f94SGreg Roach protected function monthNameLocativeCase($month_number, $leap_year) { 125a25f0a04SGreg Roach static $translated_month_names; 126a25f0a04SGreg Roach 127a25f0a04SGreg Roach if ($translated_month_names === null) { 128a25f0a04SGreg Roach $translated_month_names = array( 129a25f0a04SGreg Roach 0 => '', 130764a01d9SGreg Roach 1 => /* I18N: a month in the Jewish calendar */ I18N::translateContext('LOCATIVE', 'Tishrei'), 131764a01d9SGreg Roach 2 => /* I18N: a month in the Jewish calendar */ I18N::translateContext('LOCATIVE', 'Heshvan'), 132764a01d9SGreg Roach 3 => /* I18N: a month in the Jewish calendar */ I18N::translateContext('LOCATIVE', 'Kislev'), 133764a01d9SGreg Roach 4 => /* I18N: a month in the Jewish calendar */ I18N::translateContext('LOCATIVE', 'Tevet'), 134764a01d9SGreg Roach 5 => /* I18N: a month in the Jewish calendar */ I18N::translateContext('LOCATIVE', 'Shevat'), 135764a01d9SGreg Roach 6 => /* I18N: a month in the Jewish calendar */ I18N::translateContext('LOCATIVE', 'Adar I'), 136764a01d9SGreg Roach 7 => /* I18N: a month in the Jewish calendar */ I18N::translateContext('LOCATIVE', 'Adar'), 137764a01d9SGreg Roach -7 => /* I18N: a month in the Jewish calendar */ I18N::translateContext('LOCATIVE', 'Adar II'), 138764a01d9SGreg Roach 8 => /* I18N: a month in the Jewish calendar */ I18N::translateContext('LOCATIVE', 'Nissan'), 139764a01d9SGreg Roach 9 => /* I18N: a month in the Jewish calendar */ I18N::translateContext('LOCATIVE', 'Iyar'), 140764a01d9SGreg Roach 10 => /* I18N: a month in the Jewish calendar */ I18N::translateContext('LOCATIVE', 'Sivan'), 141764a01d9SGreg Roach 11 => /* I18N: a month in the Jewish calendar */ I18N::translateContext('LOCATIVE', 'Tamuz'), 142764a01d9SGreg Roach 12 => /* I18N: a month in the Jewish calendar */ I18N::translateContext('LOCATIVE', 'Av'), 143764a01d9SGreg Roach 13 => /* I18N: a month in the Jewish calendar */ I18N::translateContext('LOCATIVE', 'Elul'), 144a25f0a04SGreg Roach ); 145a25f0a04SGreg Roach } 146a25f0a04SGreg Roach 147a25f0a04SGreg Roach if ($month_number === 7 && $leap_year) { 148a25f0a04SGreg Roach return $translated_month_names[-7]; 149a25f0a04SGreg Roach } else { 150a25f0a04SGreg Roach return $translated_month_names[$month_number]; 151a25f0a04SGreg Roach } 152a25f0a04SGreg Roach } 153a25f0a04SGreg Roach 154a25f0a04SGreg Roach /** {@inheritdoc} */ 155*17920f94SGreg Roach protected function monthNameInstrumentalCase($month_number, $leap_year) { 156a25f0a04SGreg Roach static $translated_month_names; 157a25f0a04SGreg Roach 158a25f0a04SGreg Roach if ($translated_month_names === null) { 159a25f0a04SGreg Roach $translated_month_names = array( 160a25f0a04SGreg Roach 0 => '', 161764a01d9SGreg Roach 1 => /* I18N: a month in the Jewish calendar */ I18N::translateContext('INSTRUMENTAL', 'Tishrei'), 162764a01d9SGreg Roach 2 => /* I18N: a month in the Jewish calendar */ I18N::translateContext('INSTRUMENTAL', 'Heshvan'), 163764a01d9SGreg Roach 3 => /* I18N: a month in the Jewish calendar */ I18N::translateContext('INSTRUMENTAL', 'Kislev'), 164764a01d9SGreg Roach 4 => /* I18N: a month in the Jewish calendar */ I18N::translateContext('INSTRUMENTAL', 'Tevet'), 165764a01d9SGreg Roach 5 => /* I18N: a month in the Jewish calendar */ I18N::translateContext('INSTRUMENTAL', 'Shevat'), 166764a01d9SGreg Roach 6 => /* I18N: a month in the Jewish calendar */ I18N::translateContext('INSTRUMENTAL', 'Adar I'), 167764a01d9SGreg Roach 7 => /* I18N: a month in the Jewish calendar */ I18N::translateContext('INSTRUMENTAL', 'Adar'), 168764a01d9SGreg Roach -7 => /* I18N: a month in the Jewish calendar */ I18N::translateContext('INSTRUMENTAL', 'Adar II'), 169764a01d9SGreg Roach 8 => /* I18N: a month in the Jewish calendar */ I18N::translateContext('INSTRUMENTAL', 'Nissan'), 170764a01d9SGreg Roach 9 => /* I18N: a month in the Jewish calendar */ I18N::translateContext('INSTRUMENTAL', 'Iyar'), 171764a01d9SGreg Roach 10 => /* I18N: a month in the Jewish calendar */ I18N::translateContext('INSTRUMENTAL', 'Sivan'), 172764a01d9SGreg Roach 11 => /* I18N: a month in the Jewish calendar */ I18N::translateContext('INSTRUMENTAL', 'Tamuz'), 173764a01d9SGreg Roach 12 => /* I18N: a month in the Jewish calendar */ I18N::translateContext('INSTRUMENTAL', 'Av'), 174764a01d9SGreg Roach 13 => /* I18N: a month in the Jewish calendar */ I18N::translateContext('INSTRUMENTAL', 'Elul'), 175a25f0a04SGreg Roach ); 176a25f0a04SGreg Roach } 177a25f0a04SGreg Roach 178a25f0a04SGreg Roach if ($month_number === 7 && $leap_year) { 179a25f0a04SGreg Roach return $translated_month_names[-7]; 180a25f0a04SGreg Roach } else { 181a25f0a04SGreg Roach return $translated_month_names[$month_number]; 182a25f0a04SGreg Roach } 183a25f0a04SGreg Roach } 184a25f0a04SGreg Roach 185a25f0a04SGreg Roach /** {@inheritdoc} */ 186*17920f94SGreg Roach protected function monthNameAbbreviated($month_number, $leap_year) { 187a25f0a04SGreg Roach return self::monthNameNominativeCase($month_number, $leap_year); 188a25f0a04SGreg Roach } 189a25f0a04SGreg Roach 190a25f0a04SGreg Roach /** {@inheritdoc} */ 191a25f0a04SGreg Roach protected function nextMonth() { 192a25f0a04SGreg Roach if ($this->m == 6 && !$this->isLeapYear()) { 193a25f0a04SGreg Roach return array($this->y, 8); 194a25f0a04SGreg Roach } else { 195a25f0a04SGreg Roach return array($this->y + ($this->m == 13 ? 1 : 0), ($this->m % 13) + 1); 196a25f0a04SGreg Roach } 197a25f0a04SGreg Roach } 198a25f0a04SGreg Roach} 199