xref: /webtrees/app/Date/HijriDate.php (revision dd04c183d8beed05be2226b30b7dda485ea4538a)
1a25f0a04SGreg Roach<?php
2*dd04c183SGreg 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\ArabicCalendar;
20a25f0a04SGreg Roach
21a25f0a04SGreg Roach/**
22a25f0a04SGreg Roach * Class HijriDate - Definitions for the Hijri calendar.
23a25f0a04SGreg Roach *
24a25f0a04SGreg Roach * Note that these are "theoretical" dates.
25a25f0a04SGreg Roach * "True" dates are based on local lunar observations, and can be a +/- one day.
26a25f0a04SGreg Roach */
27a25f0a04SGreg Roachclass HijriDate extends CalendarDate {
28a25f0a04SGreg Roach	const CALENDAR_ESCAPE = '@#DHIJRI@';
29a25f0a04SGreg Roach	const CAL_START_JD = 1948440; // @#DHIJRI@ 1 MUHAR 0001 = @#JULIAN@ 16 JUL 0622
30a25f0a04SGreg Roach
31a25f0a04SGreg Roach	/** {@inheritdoc} */
32a25f0a04SGreg Roach	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);
33a25f0a04SGreg Roach
34a25f0a04SGreg Roach	/** {@inheritdoc} */
35a25f0a04SGreg Roach	public function __construct($date) {
36a25f0a04SGreg Roach		$this->calendar = new ArabicCalendar;
37a25f0a04SGreg Roach		parent::__construct($date);
38a25f0a04SGreg Roach	}
39a25f0a04SGreg Roach
40a25f0a04SGreg Roach	/** {@inheritdoc} */
41a25f0a04SGreg Roach	public static function calendarName() {
42a25f0a04SGreg Roach		return /* I18N: The Arabic/Hijri calendar */
43a25f0a04SGreg Roach			I18N::translate('Hijri');
44a25f0a04SGreg Roach	}
45a25f0a04SGreg Roach
46a25f0a04SGreg Roach	/** {@inheritdoc} */
47a25f0a04SGreg Roach	public static function monthNameNominativeCase($month_number, $leap_year) {
48a25f0a04SGreg Roach		static $translated_month_names;
49a25f0a04SGreg Roach
50a25f0a04SGreg Roach		if ($translated_month_names === null) {
51a25f0a04SGreg Roach			$translated_month_names = array(
52a25f0a04SGreg Roach				0  => '',
53a25f0a04SGreg Roach				1  => /* I18N: http://en.wikipedia.org/wiki/Muharram                     */ I18N::translate_c('NOMINATIVE', 'Muharram'),
54a25f0a04SGreg Roach				2  => /* I18N: http://en.wikipedia.org/wiki/Safar                        */ I18N::translate_c('NOMINATIVE', 'Safar'),
55a25f0a04SGreg Roach				3  => /* I18N: http://en.wikipedia.org/wiki/Rabi%27_al-awwal             */ I18N::translate_c('NOMINATIVE', 'Rabi’ al-awwal'),
56a25f0a04SGreg Roach				4  => /* I18N: http://en.wikipedia.org/wiki/Rabi%27_al-thani             */ I18N::translate_c('NOMINATIVE', 'Rabi’ al-thani'),
57a25f0a04SGreg Roach				5  => /* I18N: http://en.wikipedia.org/wiki/Jumada_al-awwal              */ I18N::translate_c('NOMINATIVE', 'Jumada al-awwal'),
58a25f0a04SGreg Roach				6  => /* I18N: http://en.wikipedia.org/wiki/Jumada_al-thani              */ I18N::translate_c('NOMINATIVE', 'Jumada al-thani'),
59a25f0a04SGreg Roach				7  => /* I18N: http://en.wikipedia.org/wiki/Rajab                        */ I18N::translate_c('NOMINATIVE', 'Rajab'),
60a25f0a04SGreg Roach				8  => /* I18N: http://en.wikipedia.org/wiki/Sha%27aban                   */ I18N::translate_c('NOMINATIVE', 'Sha’aban'),
61a25f0a04SGreg Roach				9  => /* I18N: http://en.wikipedia.org/wiki/Ramadan_%28calendar_month%29 */ I18N::translate_c('NOMINATIVE', 'Ramadan'),
62a25f0a04SGreg Roach				10 => /* I18N: http://en.wikipedia.org/wiki/Shawwal                      */ I18N::translate_c('NOMINATIVE', 'Shawwal'),
63a25f0a04SGreg Roach				11 => /* I18N: http://en.wikipedia.org/wiki/Dhu_al-Qi%27dah              */ I18N::translate_c('NOMINATIVE', 'Dhu al-Qi’dah'),
64a25f0a04SGreg Roach				12 => /* I18N: http://en.wikipedia.org/wiki/Dhu_al-Hijjah                */ I18N::translate_c('NOMINATIVE', 'Dhu al-Hijjah'),
65a25f0a04SGreg Roach			);
66a25f0a04SGreg Roach		}
67a25f0a04SGreg Roach
68a25f0a04SGreg Roach		return $translated_month_names[$month_number];
69a25f0a04SGreg Roach	}
70a25f0a04SGreg Roach
71a25f0a04SGreg Roach	/** {@inheritdoc} */
72a25f0a04SGreg Roach	static function monthNameGenitiveCase($month_number, $leap_year) {
73a25f0a04SGreg Roach		static $translated_month_names;
74a25f0a04SGreg Roach
75a25f0a04SGreg Roach		if ($translated_month_names === null) {
76a25f0a04SGreg Roach			$translated_month_names = array(
77a25f0a04SGreg Roach				0  => '',
78a25f0a04SGreg Roach				1  => /* I18N: http://en.wikipedia.org/wiki/Muharram                     */ I18N::translate_c('GENITIVE', 'Muharram'),
79a25f0a04SGreg Roach				2  => /* I18N: http://en.wikipedia.org/wiki/Safar                        */ I18N::translate_c('GENITIVE', 'Safar'),
80a25f0a04SGreg Roach				3  => /* I18N: http://en.wikipedia.org/wiki/Rabi%27_al-awwal             */ I18N::translate_c('GENITIVE', 'Rabi’ al-awwal'),
81a25f0a04SGreg Roach				4  => /* I18N: http://en.wikipedia.org/wiki/Rabi%27_al-thani             */ I18N::translate_c('GENITIVE', 'Rabi’ al-thani'),
82a25f0a04SGreg Roach				5  => /* I18N: http://en.wikipedia.org/wiki/Jumada_al-awwal              */ I18N::translate_c('GENITIVE', 'Jumada al-awwal'),
83a25f0a04SGreg Roach				6  => /* I18N: http://en.wikipedia.org/wiki/Jumada_al-thani              */ I18N::translate_c('GENITIVE', 'Jumada al-thani'),
84a25f0a04SGreg Roach				7  => /* I18N: http://en.wikipedia.org/wiki/Rajab                        */ I18N::translate_c('GENITIVE', 'Rajab'),
85a25f0a04SGreg Roach				8  => /* I18N: http://en.wikipedia.org/wiki/Sha%27aban                   */ I18N::translate_c('GENITIVE', 'Sha’aban'),
86a25f0a04SGreg Roach				9  => /* I18N: http://en.wikipedia.org/wiki/Ramadan_%28calendar_month%29 */ I18N::translate_c('GENITIVE', 'Ramadan'),
87a25f0a04SGreg Roach				10 => /* I18N: http://en.wikipedia.org/wiki/Shawwal                      */ I18N::translate_c('GENITIVE', 'Shawwal'),
88a25f0a04SGreg Roach				11 => /* I18N: http://en.wikipedia.org/wiki/Dhu_al-Qi%27dah              */ I18N::translate_c('GENITIVE', 'Dhu al-Qi’dah'),
89a25f0a04SGreg Roach				12 => /* I18N: http://en.wikipedia.org/wiki/Dhu_al-Hijjah                */ I18N::translate_c('GENITIVE', 'Dhu al-Hijjah'),
90a25f0a04SGreg Roach			);
91a25f0a04SGreg Roach		}
92a25f0a04SGreg Roach
93a25f0a04SGreg Roach		return $translated_month_names[$month_number];
94a25f0a04SGreg Roach	}
95a25f0a04SGreg Roach
96a25f0a04SGreg Roach	/** {@inheritdoc} */
97a25f0a04SGreg Roach	static function monthNameLocativeCase($month_number, $leap_year) {
98a25f0a04SGreg Roach		static $translated_month_names;
99a25f0a04SGreg Roach
100a25f0a04SGreg Roach		if ($translated_month_names === null) {
101a25f0a04SGreg Roach			$translated_month_names = array(
102a25f0a04SGreg Roach				0  => '',
103a25f0a04SGreg Roach				1  => /* I18N: http://en.wikipedia.org/wiki/Muharram                     */ I18N::translate_c('LOCATIVE', 'Muharram'),
104a25f0a04SGreg Roach				2  => /* I18N: http://en.wikipedia.org/wiki/Safar                        */ I18N::translate_c('LOCATIVE', 'Safar'),
105a25f0a04SGreg Roach				3  => /* I18N: http://en.wikipedia.org/wiki/Rabi%27_al-awwal             */ I18N::translate_c('LOCATIVE', 'Rabi’ al-awwal'),
106a25f0a04SGreg Roach				4  => /* I18N: http://en.wikipedia.org/wiki/Rabi%27_al-thani             */ I18N::translate_c('LOCATIVE', 'Rabi’ al-thani'),
107a25f0a04SGreg Roach				5  => /* I18N: http://en.wikipedia.org/wiki/Jumada_al-awwal              */ I18N::translate_c('LOCATIVE', 'Jumada al-awwal'),
108a25f0a04SGreg Roach				6  => /* I18N: http://en.wikipedia.org/wiki/Jumada_al-thani              */ I18N::translate_c('LOCATIVE', 'Jumada al-thani'),
109a25f0a04SGreg Roach				7  => /* I18N: http://en.wikipedia.org/wiki/Rajab                        */ I18N::translate_c('LOCATIVE', 'Rajab'),
110a25f0a04SGreg Roach				8  => /* I18N: http://en.wikipedia.org/wiki/Sha%27aban                   */ I18N::translate_c('LOCATIVE', 'Sha’aban'),
111a25f0a04SGreg Roach				9  => /* I18N: http://en.wikipedia.org/wiki/Ramadan_%28calendar_month%29 */ I18N::translate_c('LOCATIVE', 'Ramadan'),
112a25f0a04SGreg Roach				10 => /* I18N: http://en.wikipedia.org/wiki/Shawwal                      */ I18N::translate_c('LOCATIVE', 'Shawwal'),
113a25f0a04SGreg Roach				11 => /* I18N: http://en.wikipedia.org/wiki/Dhu_al-Qi%27dah              */ I18N::translate_c('LOCATIVE', 'Dhu al-Qi’dah'),
114a25f0a04SGreg Roach				12 => /* I18N: http://en.wikipedia.org/wiki/Dhu_al-Hijjah                */ I18N::translate_c('LOCATIVE', 'Dhu al-Hijjah'),
115a25f0a04SGreg Roach			);
116a25f0a04SGreg Roach		}
117a25f0a04SGreg Roach
118a25f0a04SGreg Roach		return $translated_month_names[$month_number];
119a25f0a04SGreg Roach	}
120a25f0a04SGreg Roach
121a25f0a04SGreg Roach	/** {@inheritdoc} */
122a25f0a04SGreg Roach	static function monthNameInstrumentalCase($month_number, $leap_year) {
123a25f0a04SGreg Roach		static $translated_month_names;
124a25f0a04SGreg Roach
125a25f0a04SGreg Roach		if ($translated_month_names === null) {
126a25f0a04SGreg Roach			$translated_month_names = array(
127a25f0a04SGreg Roach				0  => '',
128a25f0a04SGreg Roach				1  => /* I18N: http://en.wikipedia.org/wiki/Muharram                     */ I18N::translate_c('INSTRUMENTAL', 'Muharram'),
129a25f0a04SGreg Roach				2  => /* I18N: http://en.wikipedia.org/wiki/Safar                        */ I18N::translate_c('INSTRUMENTAL', 'Safar'),
130a25f0a04SGreg Roach				3  => /* I18N: http://en.wikipedia.org/wiki/Rabi%27_al-awwal             */ I18N::translate_c('INSTRUMENTAL', 'Rabi’ al-awwal'),
131a25f0a04SGreg Roach				4  => /* I18N: http://en.wikipedia.org/wiki/Rabi%27_al-thani             */ I18N::translate_c('INSTRUMENTAL', 'Rabi’ al-thani'),
132a25f0a04SGreg Roach				5  => /* I18N: http://en.wikipedia.org/wiki/Jumada_al-awwal              */ I18N::translate_c('INSTRUMENTAL', 'Jumada al-awwal'),
133a25f0a04SGreg Roach				6  => /* I18N: http://en.wikipedia.org/wiki/Jumada_al-thani              */ I18N::translate_c('INSTRUMENTAL', 'Jumada al-thani'),
134a25f0a04SGreg Roach				7  => /* I18N: http://en.wikipedia.org/wiki/Rajab                        */ I18N::translate_c('INSTRUMENTAL', 'Rajab'),
135a25f0a04SGreg Roach				8  => /* I18N: http://en.wikipedia.org/wiki/Sha%27aban                   */ I18N::translate_c('INSTRUMENTAL', 'Sha’aban'),
136a25f0a04SGreg Roach				9  => /* I18N: http://en.wikipedia.org/wiki/Ramadan_%28calendar_month%29 */ I18N::translate_c('INSTRUMENTAL', 'Ramadan'),
137a25f0a04SGreg Roach				10 => /* I18N: http://en.wikipedia.org/wiki/Shawwal                      */ I18N::translate_c('INSTRUMENTAL', 'Shawwal'),
138a25f0a04SGreg Roach				11 => /* I18N: http://en.wikipedia.org/wiki/Dhu_al-Qi%27dah              */ I18N::translate_c('INSTRUMENTAL', 'Dhu al-Qi’dah'),
139a25f0a04SGreg Roach				12 => /* I18N: http://en.wikipedia.org/wiki/Dhu_al-Hijjah                */ I18N::translate_c('INSTRUMENTAL', 'Dhu al-Hijjah'),
140a25f0a04SGreg Roach			);
141a25f0a04SGreg Roach		}
142a25f0a04SGreg Roach
143a25f0a04SGreg Roach		return $translated_month_names[$month_number];
144a25f0a04SGreg Roach	}
145a25f0a04SGreg Roach
146a25f0a04SGreg Roach	/** {@inheritdoc} */
147a25f0a04SGreg Roach	static function monthNameAbbreviated($month_number, $leap_year) {
148a25f0a04SGreg Roach		return self::monthNameNominativeCase($month_number, $leap_year);
149a25f0a04SGreg Roach	}
150a25f0a04SGreg Roach}
151