xref: /webtrees/app/Date/JalaliDate.php (revision 17920f94befaa1d6150480429428429b0bee7e3a)
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\PersianCalendar;
20a25f0a04SGreg Roach
21a25f0a04SGreg Roach/**
22a25f0a04SGreg Roach * Class JalaliDate - Definitions for the Jalali calendar
23a25f0a04SGreg Roach */
24a25f0a04SGreg Roachclass JalaliDate extends CalendarDate {
25a25f0a04SGreg Roach	/** {@inheritdoc} */
26a25f0a04SGreg Roach	public static $MONTH_ABBREV = array('' => 0, 'FARVA' => 1, 'ORDIB' => 2, 'KHORD' => 3, 'TIR' => 4, 'MORDA' => 5, 'SHAHR' => 6, 'MEHR' => 7, 'ABAN' => 8, 'AZAR' => 9, 'DEY' => 10, 'BAHMA' => 11, 'ESFAN' => 12);
27a25f0a04SGreg Roach
28a25f0a04SGreg Roach	/** {@inheritdoc} */
29a25f0a04SGreg Roach	public function __construct($date) {
30a25f0a04SGreg Roach		$this->calendar = new PersianCalendar;
31a25f0a04SGreg Roach		parent::__construct($date);
32a25f0a04SGreg Roach	}
33a25f0a04SGreg Roach
34a25f0a04SGreg Roach	/** {@inheritdoc} */
35a25f0a04SGreg Roach	public static function monthNameNominativeCase($month_number, $leap_year) {
36a25f0a04SGreg Roach		static $translated_month_names;
37a25f0a04SGreg Roach
38a25f0a04SGreg Roach		if ($translated_month_names === null) {
39a25f0a04SGreg Roach			$translated_month_names = array(
40a25f0a04SGreg Roach				0  => '',
41764a01d9SGreg Roach				1  => /* I18N: 1st month in the Persian/Jalali calendar  */ I18N::translateContext('NOMINATIVE', 'Farvardin'),
42764a01d9SGreg Roach				2  => /* I18N: 2nd month in the Persian/Jalali calendar  */ I18N::translateContext('NOMINATIVE', 'Ordibehesht'),
43764a01d9SGreg Roach				3  => /* I18N: 3rd month in the Persian/Jalali calendar  */ I18N::translateContext('NOMINATIVE', 'Khordad'),
44764a01d9SGreg Roach				4  => /* I18N: 4th month in the Persian/Jalali calendar  */ I18N::translateContext('NOMINATIVE', 'Tir'),
45764a01d9SGreg Roach				5  => /* I18N: 5th month in the Persian/Jalali calendar  */ I18N::translateContext('NOMINATIVE', 'Mordad'),
46764a01d9SGreg Roach				6  => /* I18N: 6th month in the Persian/Jalali calendar  */ I18N::translateContext('NOMINATIVE', 'Shahrivar'),
47764a01d9SGreg Roach				7  => /* I18N: 7th month in the Persian/Jalali calendar  */ I18N::translateContext('NOMINATIVE', 'Mehr'),
48764a01d9SGreg Roach				8  => /* I18N: 8th month in the Persian/Jalali calendar  */ I18N::translateContext('NOMINATIVE', 'Aban'),
49764a01d9SGreg Roach				9  => /* I18N: 9th month in the Persian/Jalali calendar  */ I18N::translateContext('NOMINATIVE', 'Azar'),
50764a01d9SGreg Roach				10 => /* I18N: 10th month in the Persian/Jalali calendar */ I18N::translateContext('NOMINATIVE', 'Dey'),
51764a01d9SGreg Roach				11 => /* I18N: 11th month in the Persian/Jalali calendar */ I18N::translateContext('NOMINATIVE', 'Bahman'),
52764a01d9SGreg Roach				12 => /* I18N: 12th month in the Persian/Jalali calendar */ I18N::translateContext('NOMINATIVE', 'Esfand'),
53a25f0a04SGreg Roach			);
54a25f0a04SGreg Roach		}
55a25f0a04SGreg Roach
56a25f0a04SGreg Roach		return $translated_month_names[$month_number];
57a25f0a04SGreg Roach	}
58a25f0a04SGreg Roach
59a25f0a04SGreg Roach	/** {@inheritdoc} */
60*17920f94SGreg Roach	protected function monthNameGenitiveCase($month_number, $leap_year) {
61a25f0a04SGreg Roach		static $translated_month_names;
62a25f0a04SGreg Roach
63a25f0a04SGreg Roach		if ($translated_month_names === null) {
64a25f0a04SGreg Roach			$translated_month_names = array(
65a25f0a04SGreg Roach				0  => '',
66764a01d9SGreg Roach				1  => /* I18N: 1st month in the Persian/Jalali calendar  */ I18N::translateContext('GENITIVE', 'Farvardin'),
67764a01d9SGreg Roach				2  => /* I18N: 2nd month in the Persian/Jalali calendar  */ I18N::translateContext('GENITIVE', 'Ordibehesht'),
68764a01d9SGreg Roach				3  => /* I18N: 3rd month in the Persian/Jalali calendar  */ I18N::translateContext('GENITIVE', 'Khordad'),
69764a01d9SGreg Roach				4  => /* I18N: 4th month in the Persian/Jalali calendar  */ I18N::translateContext('GENITIVE', 'Tir'),
70764a01d9SGreg Roach				5  => /* I18N: 5th month in the Persian/Jalali calendar  */ I18N::translateContext('GENITIVE', 'Mordad'),
71764a01d9SGreg Roach				6  => /* I18N: 6th month in the Persian/Jalali calendar  */ I18N::translateContext('GENITIVE', 'Shahrivar'),
72764a01d9SGreg Roach				7  => /* I18N: 7th month in the Persian/Jalali calendar  */ I18N::translateContext('GENITIVE', 'Mehr'),
73764a01d9SGreg Roach				8  => /* I18N: 8th month in the Persian/Jalali calendar  */ I18N::translateContext('GENITIVE', 'Aban'),
74764a01d9SGreg Roach				9  => /* I18N: 9th month in the Persian/Jalali calendar  */ I18N::translateContext('GENITIVE', 'Azar'),
75764a01d9SGreg Roach				10 => /* I18N: 10th month in the Persian/Jalali calendar */ I18N::translateContext('GENITIVE', 'Dey'),
76764a01d9SGreg Roach				11 => /* I18N: 11th month in the Persian/Jalali calendar */ I18N::translateContext('GENITIVE', 'Bahman'),
77764a01d9SGreg Roach				12 => /* I18N: 12th month in the Persian/Jalali calendar */ I18N::translateContext('GENITIVE', 'Esfand'),
78a25f0a04SGreg Roach			);
79a25f0a04SGreg Roach		}
80a25f0a04SGreg Roach
81a25f0a04SGreg Roach		return $translated_month_names[$month_number];
82a25f0a04SGreg Roach	}
83a25f0a04SGreg Roach
84a25f0a04SGreg Roach	/** {@inheritdoc} */
85*17920f94SGreg Roach	protected function monthNameLocativeCase($month_number, $leap_year) {
86a25f0a04SGreg Roach		static $translated_month_names;
87a25f0a04SGreg Roach
88a25f0a04SGreg Roach		if ($translated_month_names === null) {
89a25f0a04SGreg Roach			$translated_month_names = array(
90a25f0a04SGreg Roach				0  => '',
91764a01d9SGreg Roach				1  => /* I18N: 1st month in the Persian/Jalali calendar  */ I18N::translateContext('LOCATIVE', 'Farvardin'),
92764a01d9SGreg Roach				2  => /* I18N: 2nd month in the Persian/Jalali calendar  */ I18N::translateContext('LOCATIVE', 'Ordibehesht'),
93764a01d9SGreg Roach				3  => /* I18N: 3rd month in the Persian/Jalali calendar  */ I18N::translateContext('LOCATIVE', 'Khordad'),
94764a01d9SGreg Roach				4  => /* I18N: 4th month in the Persian/Jalali calendar  */ I18N::translateContext('LOCATIVE', 'Tir'),
95764a01d9SGreg Roach				5  => /* I18N: 5th month in the Persian/Jalali calendar  */ I18N::translateContext('LOCATIVE', 'Mordad'),
96764a01d9SGreg Roach				6  => /* I18N: 6th month in the Persian/Jalali calendar  */ I18N::translateContext('LOCATIVE', 'Shahrivar'),
97764a01d9SGreg Roach				7  => /* I18N: 7th month in the Persian/Jalali calendar  */ I18N::translateContext('LOCATIVE', 'Mehr'),
98764a01d9SGreg Roach				8  => /* I18N: 8th month in the Persian/Jalali calendar  */ I18N::translateContext('LOCATIVE', 'Aban'),
99764a01d9SGreg Roach				9  => /* I18N: 9th month in the Persian/Jalali calendar  */ I18N::translateContext('LOCATIVE', 'Azar'),
100764a01d9SGreg Roach				10 => /* I18N: 10th month in the Persian/Jalali calendar */ I18N::translateContext('LOCATIVE', 'Dey'),
101764a01d9SGreg Roach				11 => /* I18N: 11th month in the Persian/Jalali calendar */ I18N::translateContext('LOCATIVE', 'Bahman'),
102764a01d9SGreg Roach				12 => /* I18N: 12th month in the Persian/Jalali calendar */ I18N::translateContext('LOCATIVE', 'Esfand'),
103a25f0a04SGreg Roach			);
104a25f0a04SGreg Roach		}
105a25f0a04SGreg Roach
106a25f0a04SGreg Roach		return $translated_month_names[$month_number];
107a25f0a04SGreg Roach	}
108a25f0a04SGreg Roach
109a25f0a04SGreg Roach	/** {@inheritdoc} */
110*17920f94SGreg Roach	protected function monthNameInstrumentalCase($month_number, $leap_year) {
111a25f0a04SGreg Roach		static $translated_month_names;
112a25f0a04SGreg Roach
113a25f0a04SGreg Roach		if ($translated_month_names === null) {
114a25f0a04SGreg Roach			$translated_month_names = array(
115a25f0a04SGreg Roach				0  => '',
116764a01d9SGreg Roach				1  => /* I18N: 1st month in the Persian/Jalali calendar  */ I18N::translateContext('INSTRUMENTAL', 'Farvardin'),
117764a01d9SGreg Roach				2  => /* I18N: 2nd month in the Persian/Jalali calendar  */ I18N::translateContext('INSTRUMENTAL', 'Ordibehesht'),
118764a01d9SGreg Roach				3  => /* I18N: 3rd month in the Persian/Jalali calendar  */ I18N::translateContext('INSTRUMENTAL', 'Khordad'),
119764a01d9SGreg Roach				4  => /* I18N: 4th month in the Persian/Jalali calendar  */ I18N::translateContext('INSTRUMENTAL', 'Tir'),
120764a01d9SGreg Roach				5  => /* I18N: 5th month in the Persian/Jalali calendar  */ I18N::translateContext('INSTRUMENTAL', 'Mordad'),
121764a01d9SGreg Roach				6  => /* I18N: 6th month in the Persian/Jalali calendar  */ I18N::translateContext('INSTRUMENTAL', 'Shahrivar'),
122764a01d9SGreg Roach				7  => /* I18N: 7th month in the Persian/Jalali calendar  */ I18N::translateContext('INSTRUMENTAL', 'Mehr'),
123764a01d9SGreg Roach				8  => /* I18N: 8th month in the Persian/Jalali calendar  */ I18N::translateContext('INSTRUMENTAL', 'Aban'),
124764a01d9SGreg Roach				9  => /* I18N: 9th month in the Persian/Jalali calendar  */ I18N::translateContext('INSTRUMENTAL', 'Azar'),
125764a01d9SGreg Roach				10 => /* I18N: 10th month in the Persian/Jalali calendar */ I18N::translateContext('INSTRUMENTAL', 'Dey'),
126764a01d9SGreg Roach				11 => /* I18N: 11th month in the Persian/Jalali calendar */ I18N::translateContext('INSTRUMENTAL', 'Bahman'),
127764a01d9SGreg Roach				12 => /* I18N: 12th month in the Persian/Jalali calendar */ I18N::translateContext('INSTRUMENTAL', 'Esfand'),
128a25f0a04SGreg Roach			);
129a25f0a04SGreg Roach		}
130a25f0a04SGreg Roach
131a25f0a04SGreg Roach		return $translated_month_names[$month_number];
132a25f0a04SGreg Roach	}
133a25f0a04SGreg Roach
134a25f0a04SGreg Roach	/** {@inheritdoc} */
135*17920f94SGreg Roach	protected function monthNameAbbreviated($month_number, $leap_year) {
136a25f0a04SGreg Roach		static $translated_month_names;
137a25f0a04SGreg Roach
138a25f0a04SGreg Roach		if ($translated_month_names === null) {
139a25f0a04SGreg Roach			$translated_month_names = array(
140a25f0a04SGreg Roach				0  => '',
141764a01d9SGreg Roach				1  => I18N::translateContext('Abbreviation for Persian month: Farvardin', 'Far'),
142764a01d9SGreg Roach				2  => I18N::translateContext('Abbreviation for Persian month: Ordibehesht', 'Ord'),
143764a01d9SGreg Roach				3  => I18N::translateContext('Abbreviation for Persian month: Khordad', 'Khor'),
144764a01d9SGreg Roach				4  => I18N::translateContext('Abbreviation for Persian month: Tir', 'Tir'),
145764a01d9SGreg Roach				5  => I18N::translateContext('Abbreviation for Persian month: Mordad', 'Mor'),
146764a01d9SGreg Roach				6  => I18N::translateContext('Abbreviation for Persian month: Shahrivar', 'Shah'),
147764a01d9SGreg Roach				7  => I18N::translateContext('Abbreviation for Persian month: Mehr', 'Mehr'),
148764a01d9SGreg Roach				8  => I18N::translateContext('Abbreviation for Persian month: Aban', 'Aban'),
149764a01d9SGreg Roach				9  => I18N::translateContext('Abbreviation for Persian month: Azar', 'Azar'),
150764a01d9SGreg Roach				10 => I18N::translateContext('Abbreviation for Persian month: Dey', 'Dey'),
151764a01d9SGreg Roach				11 => I18N::translateContext('Abbreviation for Persian month: Bahman', 'Bah'),
152764a01d9SGreg Roach				12 => I18N::translateContext('Abbreviation for Persian month: Esfand', 'Esf'),
153a25f0a04SGreg Roach			);
154a25f0a04SGreg Roach		}
155a25f0a04SGreg Roach
156a25f0a04SGreg Roach		return $translated_month_names[$month_number];
157a25f0a04SGreg Roach	}
158a25f0a04SGreg Roach}
159