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