xref: /webtrees/app/Date/HijriDate.php (revision ffd703ea1e658c7dcb5e5f1f9ef137a420f2d167)
1<?php
2namespace Fisharebest\Webtrees;
3
4/**
5 * webtrees: online genealogy
6 * Copyright (C) 2015 webtrees development team
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19use Fisharebest\ExtCalendar\ArabicCalendar;
20
21/**
22 * Class HijriDate - Definitions for the Hijri calendar.
23 *
24 * Note that these are "theoretical" dates.
25 * "True" dates are based on local lunar observations, and can be a +/- one day.
26 */
27class HijriDate extends CalendarDate {
28	/** {@inheritdoc} */
29	public static $MONTH_ABBREV = array('' => 0, 'MUHAR' => 1, 'SAFAR' => 2, 'RABIA' => 3, 'RABIT' => 4, 'JUMAA' => 5, 'JUMAT' => 6, 'RAJAB' => 7, 'SHAAB' => 8, 'RAMAD' => 9, 'SHAWW' => 10, 'DHUAQ' => 11, 'DHUAH' => 12);
30
31	/** {@inheritdoc} */
32	public function __construct($date) {
33		$this->calendar = new ArabicCalendar;
34		parent::__construct($date);
35	}
36
37	/** {@inheritdoc} */
38	public static function monthNameNominativeCase($month_number, $leap_year) {
39		static $translated_month_names;
40
41		if ($translated_month_names === null) {
42			$translated_month_names = array(
43				0  => '',
44				1  => /* I18N: http://en.wikipedia.org/wiki/Muharram                     */ I18N::translateContext('NOMINATIVE', 'Muharram'),
45				2  => /* I18N: http://en.wikipedia.org/wiki/Safar                        */ I18N::translateContext('NOMINATIVE', 'Safar'),
46				3  => /* I18N: http://en.wikipedia.org/wiki/Rabi%27_al-awwal             */ I18N::translateContext('NOMINATIVE', 'Rabi’ al-awwal'),
47				4  => /* I18N: http://en.wikipedia.org/wiki/Rabi%27_al-thani             */ I18N::translateContext('NOMINATIVE', 'Rabi’ al-thani'),
48				5  => /* I18N: http://en.wikipedia.org/wiki/Jumada_al-awwal              */ I18N::translateContext('NOMINATIVE', 'Jumada al-awwal'),
49				6  => /* I18N: http://en.wikipedia.org/wiki/Jumada_al-thani              */ I18N::translateContext('NOMINATIVE', 'Jumada al-thani'),
50				7  => /* I18N: http://en.wikipedia.org/wiki/Rajab                        */ I18N::translateContext('NOMINATIVE', 'Rajab'),
51				8  => /* I18N: http://en.wikipedia.org/wiki/Sha%27aban                   */ I18N::translateContext('NOMINATIVE', 'Sha’aban'),
52				9  => /* I18N: http://en.wikipedia.org/wiki/Ramadan_%28calendar_month%29 */ I18N::translateContext('NOMINATIVE', 'Ramadan'),
53				10 => /* I18N: http://en.wikipedia.org/wiki/Shawwal                      */ I18N::translateContext('NOMINATIVE', 'Shawwal'),
54				11 => /* I18N: http://en.wikipedia.org/wiki/Dhu_al-Qi%27dah              */ I18N::translateContext('NOMINATIVE', 'Dhu al-Qi’dah'),
55				12 => /* I18N: http://en.wikipedia.org/wiki/Dhu_al-Hijjah                */ I18N::translateContext('NOMINATIVE', 'Dhu al-Hijjah'),
56			);
57		}
58
59		return $translated_month_names[$month_number];
60	}
61
62	/** {@inheritdoc} */
63	protected function monthNameGenitiveCase($month_number, $leap_year) {
64		static $translated_month_names;
65
66		if ($translated_month_names === null) {
67			$translated_month_names = array(
68				0  => '',
69				1  => /* I18N: http://en.wikipedia.org/wiki/Muharram                     */ I18N::translateContext('GENITIVE', 'Muharram'),
70				2  => /* I18N: http://en.wikipedia.org/wiki/Safar                        */ I18N::translateContext('GENITIVE', 'Safar'),
71				3  => /* I18N: http://en.wikipedia.org/wiki/Rabi%27_al-awwal             */ I18N::translateContext('GENITIVE', 'Rabi’ al-awwal'),
72				4  => /* I18N: http://en.wikipedia.org/wiki/Rabi%27_al-thani             */ I18N::translateContext('GENITIVE', 'Rabi’ al-thani'),
73				5  => /* I18N: http://en.wikipedia.org/wiki/Jumada_al-awwal              */ I18N::translateContext('GENITIVE', 'Jumada al-awwal'),
74				6  => /* I18N: http://en.wikipedia.org/wiki/Jumada_al-thani              */ I18N::translateContext('GENITIVE', 'Jumada al-thani'),
75				7  => /* I18N: http://en.wikipedia.org/wiki/Rajab                        */ I18N::translateContext('GENITIVE', 'Rajab'),
76				8  => /* I18N: http://en.wikipedia.org/wiki/Sha%27aban                   */ I18N::translateContext('GENITIVE', 'Sha’aban'),
77				9  => /* I18N: http://en.wikipedia.org/wiki/Ramadan_%28calendar_month%29 */ I18N::translateContext('GENITIVE', 'Ramadan'),
78				10 => /* I18N: http://en.wikipedia.org/wiki/Shawwal                      */ I18N::translateContext('GENITIVE', 'Shawwal'),
79				11 => /* I18N: http://en.wikipedia.org/wiki/Dhu_al-Qi%27dah              */ I18N::translateContext('GENITIVE', 'Dhu al-Qi’dah'),
80				12 => /* I18N: http://en.wikipedia.org/wiki/Dhu_al-Hijjah                */ I18N::translateContext('GENITIVE', 'Dhu al-Hijjah'),
81			);
82		}
83
84		return $translated_month_names[$month_number];
85	}
86
87	/** {@inheritdoc} */
88	protected function monthNameLocativeCase($month_number, $leap_year) {
89		static $translated_month_names;
90
91		if ($translated_month_names === null) {
92			$translated_month_names = array(
93				0  => '',
94				1  => /* I18N: http://en.wikipedia.org/wiki/Muharram                     */ I18N::translateContext('LOCATIVE', 'Muharram'),
95				2  => /* I18N: http://en.wikipedia.org/wiki/Safar                        */ I18N::translateContext('LOCATIVE', 'Safar'),
96				3  => /* I18N: http://en.wikipedia.org/wiki/Rabi%27_al-awwal             */ I18N::translateContext('LOCATIVE', 'Rabi’ al-awwal'),
97				4  => /* I18N: http://en.wikipedia.org/wiki/Rabi%27_al-thani             */ I18N::translateContext('LOCATIVE', 'Rabi’ al-thani'),
98				5  => /* I18N: http://en.wikipedia.org/wiki/Jumada_al-awwal              */ I18N::translateContext('LOCATIVE', 'Jumada al-awwal'),
99				6  => /* I18N: http://en.wikipedia.org/wiki/Jumada_al-thani              */ I18N::translateContext('LOCATIVE', 'Jumada al-thani'),
100				7  => /* I18N: http://en.wikipedia.org/wiki/Rajab                        */ I18N::translateContext('LOCATIVE', 'Rajab'),
101				8  => /* I18N: http://en.wikipedia.org/wiki/Sha%27aban                   */ I18N::translateContext('LOCATIVE', 'Sha’aban'),
102				9  => /* I18N: http://en.wikipedia.org/wiki/Ramadan_%28calendar_month%29 */ I18N::translateContext('LOCATIVE', 'Ramadan'),
103				10 => /* I18N: http://en.wikipedia.org/wiki/Shawwal                      */ I18N::translateContext('LOCATIVE', 'Shawwal'),
104				11 => /* I18N: http://en.wikipedia.org/wiki/Dhu_al-Qi%27dah              */ I18N::translateContext('LOCATIVE', 'Dhu al-Qi’dah'),
105				12 => /* I18N: http://en.wikipedia.org/wiki/Dhu_al-Hijjah                */ I18N::translateContext('LOCATIVE', 'Dhu al-Hijjah'),
106			);
107		}
108
109		return $translated_month_names[$month_number];
110	}
111
112	/** {@inheritdoc} */
113	protected function monthNameInstrumentalCase($month_number, $leap_year) {
114		static $translated_month_names;
115
116		if ($translated_month_names === null) {
117			$translated_month_names = array(
118				0  => '',
119				1  => /* I18N: http://en.wikipedia.org/wiki/Muharram                     */ I18N::translateContext('INSTRUMENTAL', 'Muharram'),
120				2  => /* I18N: http://en.wikipedia.org/wiki/Safar                        */ I18N::translateContext('INSTRUMENTAL', 'Safar'),
121				3  => /* I18N: http://en.wikipedia.org/wiki/Rabi%27_al-awwal             */ I18N::translateContext('INSTRUMENTAL', 'Rabi’ al-awwal'),
122				4  => /* I18N: http://en.wikipedia.org/wiki/Rabi%27_al-thani             */ I18N::translateContext('INSTRUMENTAL', 'Rabi’ al-thani'),
123				5  => /* I18N: http://en.wikipedia.org/wiki/Jumada_al-awwal              */ I18N::translateContext('INSTRUMENTAL', 'Jumada al-awwal'),
124				6  => /* I18N: http://en.wikipedia.org/wiki/Jumada_al-thani              */ I18N::translateContext('INSTRUMENTAL', 'Jumada al-thani'),
125				7  => /* I18N: http://en.wikipedia.org/wiki/Rajab                        */ I18N::translateContext('INSTRUMENTAL', 'Rajab'),
126				8  => /* I18N: http://en.wikipedia.org/wiki/Sha%27aban                   */ I18N::translateContext('INSTRUMENTAL', 'Sha’aban'),
127				9  => /* I18N: http://en.wikipedia.org/wiki/Ramadan_%28calendar_month%29 */ I18N::translateContext('INSTRUMENTAL', 'Ramadan'),
128				10 => /* I18N: http://en.wikipedia.org/wiki/Shawwal                      */ I18N::translateContext('INSTRUMENTAL', 'Shawwal'),
129				11 => /* I18N: http://en.wikipedia.org/wiki/Dhu_al-Qi%27dah              */ I18N::translateContext('INSTRUMENTAL', 'Dhu al-Qi’dah'),
130				12 => /* I18N: http://en.wikipedia.org/wiki/Dhu_al-Hijjah                */ I18N::translateContext('INSTRUMENTAL', 'Dhu al-Hijjah'),
131			);
132		}
133
134		return $translated_month_names[$month_number];
135	}
136
137	/** {@inheritdoc} */
138	protected function monthNameAbbreviated($month_number, $leap_year) {
139		return self::monthNameNominativeCase($month_number, $leap_year);
140	}
141}
142