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\PersianCalendar; 20 21/** 22 * Class JalaliDate - Definitions for the Jalali calendar 23 */ 24class JalaliDate extends CalendarDate { 25 const CALENDAR_ESCAPE = '@#DJALALI@'; 26 const CAL_START_JD = 1948321; 27 28 /** {@inheritdoc} */ 29 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); 30 31 /** {@inheritdoc} */ 32 public function __construct($date) { 33 $this->calendar = new PersianCalendar; 34 parent::__construct($date); 35 } 36 37 /** {@inheritdoc} */ 38 public static function calendarName() { 39 return /* I18N: The Persian/Jalali calendar */ 40 I18N::translate('Jalali'); 41 } 42 43 /** {@inheritdoc} */ 44 public static function monthNameNominativeCase($month_number, $leap_year) { 45 static $translated_month_names; 46 47 if ($translated_month_names === null) { 48 $translated_month_names = array( 49 0 => '', 50 1 => /* I18N: 1st month in the Persian/Jalali calendar */ I18N::translateContext('NOMINATIVE', 'Farvardin'), 51 2 => /* I18N: 2nd month in the Persian/Jalali calendar */ I18N::translateContext('NOMINATIVE', 'Ordibehesht'), 52 3 => /* I18N: 3rd month in the Persian/Jalali calendar */ I18N::translateContext('NOMINATIVE', 'Khordad'), 53 4 => /* I18N: 4th month in the Persian/Jalali calendar */ I18N::translateContext('NOMINATIVE', 'Tir'), 54 5 => /* I18N: 5th month in the Persian/Jalali calendar */ I18N::translateContext('NOMINATIVE', 'Mordad'), 55 6 => /* I18N: 6th month in the Persian/Jalali calendar */ I18N::translateContext('NOMINATIVE', 'Shahrivar'), 56 7 => /* I18N: 7th month in the Persian/Jalali calendar */ I18N::translateContext('NOMINATIVE', 'Mehr'), 57 8 => /* I18N: 8th month in the Persian/Jalali calendar */ I18N::translateContext('NOMINATIVE', 'Aban'), 58 9 => /* I18N: 9th month in the Persian/Jalali calendar */ I18N::translateContext('NOMINATIVE', 'Azar'), 59 10 => /* I18N: 10th month in the Persian/Jalali calendar */ I18N::translateContext('NOMINATIVE', 'Dey'), 60 11 => /* I18N: 11th month in the Persian/Jalali calendar */ I18N::translateContext('NOMINATIVE', 'Bahman'), 61 12 => /* I18N: 12th month in the Persian/Jalali calendar */ I18N::translateContext('NOMINATIVE', 'Esfand'), 62 ); 63 } 64 65 return $translated_month_names[$month_number]; 66 } 67 68 /** {@inheritdoc} */ 69 static function monthNameGenitiveCase($month_number, $leap_year) { 70 static $translated_month_names; 71 72 if ($translated_month_names === null) { 73 $translated_month_names = array( 74 0 => '', 75 1 => /* I18N: 1st month in the Persian/Jalali calendar */ I18N::translateContext('GENITIVE', 'Farvardin'), 76 2 => /* I18N: 2nd month in the Persian/Jalali calendar */ I18N::translateContext('GENITIVE', 'Ordibehesht'), 77 3 => /* I18N: 3rd month in the Persian/Jalali calendar */ I18N::translateContext('GENITIVE', 'Khordad'), 78 4 => /* I18N: 4th month in the Persian/Jalali calendar */ I18N::translateContext('GENITIVE', 'Tir'), 79 5 => /* I18N: 5th month in the Persian/Jalali calendar */ I18N::translateContext('GENITIVE', 'Mordad'), 80 6 => /* I18N: 6th month in the Persian/Jalali calendar */ I18N::translateContext('GENITIVE', 'Shahrivar'), 81 7 => /* I18N: 7th month in the Persian/Jalali calendar */ I18N::translateContext('GENITIVE', 'Mehr'), 82 8 => /* I18N: 8th month in the Persian/Jalali calendar */ I18N::translateContext('GENITIVE', 'Aban'), 83 9 => /* I18N: 9th month in the Persian/Jalali calendar */ I18N::translateContext('GENITIVE', 'Azar'), 84 10 => /* I18N: 10th month in the Persian/Jalali calendar */ I18N::translateContext('GENITIVE', 'Dey'), 85 11 => /* I18N: 11th month in the Persian/Jalali calendar */ I18N::translateContext('GENITIVE', 'Bahman'), 86 12 => /* I18N: 12th month in the Persian/Jalali calendar */ I18N::translateContext('GENITIVE', 'Esfand'), 87 ); 88 } 89 90 return $translated_month_names[$month_number]; 91 } 92 93 /** {@inheritdoc} */ 94 static function monthNameLocativeCase($month_number, $leap_year) { 95 static $translated_month_names; 96 97 if ($translated_month_names === null) { 98 $translated_month_names = array( 99 0 => '', 100 1 => /* I18N: 1st month in the Persian/Jalali calendar */ I18N::translateContext('LOCATIVE', 'Farvardin'), 101 2 => /* I18N: 2nd month in the Persian/Jalali calendar */ I18N::translateContext('LOCATIVE', 'Ordibehesht'), 102 3 => /* I18N: 3rd month in the Persian/Jalali calendar */ I18N::translateContext('LOCATIVE', 'Khordad'), 103 4 => /* I18N: 4th month in the Persian/Jalali calendar */ I18N::translateContext('LOCATIVE', 'Tir'), 104 5 => /* I18N: 5th month in the Persian/Jalali calendar */ I18N::translateContext('LOCATIVE', 'Mordad'), 105 6 => /* I18N: 6th month in the Persian/Jalali calendar */ I18N::translateContext('LOCATIVE', 'Shahrivar'), 106 7 => /* I18N: 7th month in the Persian/Jalali calendar */ I18N::translateContext('LOCATIVE', 'Mehr'), 107 8 => /* I18N: 8th month in the Persian/Jalali calendar */ I18N::translateContext('LOCATIVE', 'Aban'), 108 9 => /* I18N: 9th month in the Persian/Jalali calendar */ I18N::translateContext('LOCATIVE', 'Azar'), 109 10 => /* I18N: 10th month in the Persian/Jalali calendar */ I18N::translateContext('LOCATIVE', 'Dey'), 110 11 => /* I18N: 11th month in the Persian/Jalali calendar */ I18N::translateContext('LOCATIVE', 'Bahman'), 111 12 => /* I18N: 12th month in the Persian/Jalali calendar */ I18N::translateContext('LOCATIVE', 'Esfand'), 112 ); 113 } 114 115 return $translated_month_names[$month_number]; 116 } 117 118 /** {@inheritdoc} */ 119 static function monthNameInstrumentalCase($month_number, $leap_year) { 120 static $translated_month_names; 121 122 if ($translated_month_names === null) { 123 $translated_month_names = array( 124 0 => '', 125 1 => /* I18N: 1st month in the Persian/Jalali calendar */ I18N::translateContext('INSTRUMENTAL', 'Farvardin'), 126 2 => /* I18N: 2nd month in the Persian/Jalali calendar */ I18N::translateContext('INSTRUMENTAL', 'Ordibehesht'), 127 3 => /* I18N: 3rd month in the Persian/Jalali calendar */ I18N::translateContext('INSTRUMENTAL', 'Khordad'), 128 4 => /* I18N: 4th month in the Persian/Jalali calendar */ I18N::translateContext('INSTRUMENTAL', 'Tir'), 129 5 => /* I18N: 5th month in the Persian/Jalali calendar */ I18N::translateContext('INSTRUMENTAL', 'Mordad'), 130 6 => /* I18N: 6th month in the Persian/Jalali calendar */ I18N::translateContext('INSTRUMENTAL', 'Shahrivar'), 131 7 => /* I18N: 7th month in the Persian/Jalali calendar */ I18N::translateContext('INSTRUMENTAL', 'Mehr'), 132 8 => /* I18N: 8th month in the Persian/Jalali calendar */ I18N::translateContext('INSTRUMENTAL', 'Aban'), 133 9 => /* I18N: 9th month in the Persian/Jalali calendar */ I18N::translateContext('INSTRUMENTAL', 'Azar'), 134 10 => /* I18N: 10th month in the Persian/Jalali calendar */ I18N::translateContext('INSTRUMENTAL', 'Dey'), 135 11 => /* I18N: 11th month in the Persian/Jalali calendar */ I18N::translateContext('INSTRUMENTAL', 'Bahman'), 136 12 => /* I18N: 12th month in the Persian/Jalali calendar */ I18N::translateContext('INSTRUMENTAL', 'Esfand'), 137 ); 138 } 139 140 return $translated_month_names[$month_number]; 141 } 142 143 /** {@inheritdoc} */ 144 static function monthNameAbbreviated($month_number, $leap_year) { 145 static $translated_month_names; 146 147 if ($translated_month_names === null) { 148 $translated_month_names = array( 149 0 => '', 150 1 => I18N::translateContext('Abbreviation for Persian month: Farvardin', 'Far'), 151 2 => I18N::translateContext('Abbreviation for Persian month: Ordibehesht', 'Ord'), 152 3 => I18N::translateContext('Abbreviation for Persian month: Khordad', 'Khor'), 153 4 => I18N::translateContext('Abbreviation for Persian month: Tir', 'Tir'), 154 5 => I18N::translateContext('Abbreviation for Persian month: Mordad', 'Mor'), 155 6 => I18N::translateContext('Abbreviation for Persian month: Shahrivar', 'Shah'), 156 7 => I18N::translateContext('Abbreviation for Persian month: Mehr', 'Mehr'), 157 8 => I18N::translateContext('Abbreviation for Persian month: Aban', 'Aban'), 158 9 => I18N::translateContext('Abbreviation for Persian month: Azar', 'Azar'), 159 10 => I18N::translateContext('Abbreviation for Persian month: Dey', 'Dey'), 160 11 => I18N::translateContext('Abbreviation for Persian month: Bahman', 'Bah'), 161 12 => I18N::translateContext('Abbreviation for Persian month: Esfand', 'Esf'), 162 ); 163 } 164 165 return $translated_month_names[$month_number]; 166 } 167} 168