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\FrenchCalendar; 20 21/** 22 * Class FrenchDate - Definitions for the French Republican calendar 23 */ 24class FrenchDate extends CalendarDate { 25 const CALENDAR_ESCAPE = '@#DFRENCH R@'; 26 const MONTHS_IN_YEAR = 13; 27 const CAL_START_JD = 2375840; // 22 SEP 1792 = 01 VEND 0001 28 const CAL_END_JD = 2380687; // 31 DEC 1805 = 10 NIVO 0014 29 const DAYS_IN_WEEK = 10; // A metric week of 10 unimaginatively named days. 30 31 /** {@inheritdoc} */ 32 public static $MONTH_ABBREV = array('' => 0, 'VEND' => 1, 'BRUM' => 2, 'FRIM' => 3, 'NIVO' => 4, 'PLUV' => 5, 'VENT' => 6, 'GERM' => 7, 'FLOR' => 8, 'PRAI' => 9, 'MESS' => 10, 'THER' => 11, 'FRUC' => 12, 'COMP' => 13); 33 34 /** {@inheritdoc} */ 35 public function __construct($date) { 36 $this->calendar = new FrenchCalendar; 37 parent::__construct($date); 38 } 39 40 /** {@inheritdoc} */ 41 public static function calendarName() { 42 return /* I18N: The French calendar */ I18N::translate('French'); 43 } 44 45 /** {@inheritdoc} */ 46 public static function monthNameNominativeCase($month_number, $leap_year) { 47 static $translated_month_names; 48 49 if ($translated_month_names === null) { 50 $translated_month_names = array( 51 0 => '', 52 1 => /* I18N: a month in the French republican calendar */ I18N::translateContext('NOMINATIVE', 'Vendémiaire'), 53 2 => /* I18N: a month in the French republican calendar */ I18N::translateContext('NOMINATIVE', 'Brumaire'), 54 3 => /* I18N: a month in the French republican calendar */ I18N::translateContext('NOMINATIVE', 'Frimaire'), 55 4 => /* I18N: a month in the French republican calendar */ I18N::translateContext('NOMINATIVE', 'Nivôse'), 56 5 => /* I18N: a month in the French republican calendar */ I18N::translateContext('NOMINATIVE', 'Pluviôse'), 57 6 => /* I18N: a month in the French republican calendar */ I18N::translateContext('NOMINATIVE', 'Ventôse'), 58 7 => /* I18N: a month in the French republican calendar */ I18N::translateContext('NOMINATIVE', 'Germinal'), 59 8 => /* I18N: a month in the French republican calendar */ I18N::translateContext('NOMINATIVE', 'Floréal'), 60 9 => /* I18N: a month in the French republican calendar */ I18N::translateContext('NOMINATIVE', 'Prairial'), 61 10 => /* I18N: a month in the French republican calendar */ I18N::translateContext('NOMINATIVE', 'Messidor'), 62 11 => /* I18N: a month in the French republican calendar */ I18N::translateContext('NOMINATIVE', 'Thermidor'), 63 12 => /* I18N: a month in the French republican calendar */ I18N::translateContext('NOMINATIVE', 'Fructidor'), 64 13 => /* I18N: a month in the French republican calendar */ I18N::translateContext('NOMINATIVE', 'jours complémentaires'), 65 ); 66 } 67 68 return $translated_month_names[$month_number]; 69 } 70 71 /** {@inheritdoc} */ 72 static function monthNameGenitiveCase($month_number, $leap_year) { 73 static $translated_month_names; 74 75 if ($translated_month_names === null) { 76 $translated_month_names = array( 77 0 => '', 78 1 => /* I18N: a month in the French republican calendar */ I18N::translateContext('GENITIVE', 'Vendémiaire'), 79 2 => /* I18N: a month in the French republican calendar */ I18N::translateContext('GENITIVE', 'Brumaire'), 80 3 => /* I18N: a month in the French republican calendar */ I18N::translateContext('GENITIVE', 'Frimaire'), 81 4 => /* I18N: a month in the French republican calendar */ I18N::translateContext('GENITIVE', 'Nivôse'), 82 5 => /* I18N: a month in the French republican calendar */ I18N::translateContext('GENITIVE', 'Pluviôse'), 83 6 => /* I18N: a month in the French republican calendar */ I18N::translateContext('GENITIVE', 'Ventôse'), 84 7 => /* I18N: a month in the French republican calendar */ I18N::translateContext('GENITIVE', 'Germinal'), 85 8 => /* I18N: a month in the French republican calendar */ I18N::translateContext('GENITIVE', 'Floréal'), 86 9 => /* I18N: a month in the French republican calendar */ I18N::translateContext('GENITIVE', 'Prairial'), 87 10 => /* I18N: a month in the French republican calendar */ I18N::translateContext('GENITIVE', 'Messidor'), 88 11 => /* I18N: a month in the French republican calendar */ I18N::translateContext('GENITIVE', 'Thermidor'), 89 12 => /* I18N: a month in the French republican calendar */ I18N::translateContext('GENITIVE', 'Fructidor'), 90 13 => /* I18N: a month in the French republican calendar */ I18N::translateContext('GENITIVE', 'jours complémentaires'), 91 ); 92 } 93 94 return $translated_month_names[$month_number]; 95 } 96 97 /** {@inheritdoc} */ 98 static function monthNameLocativeCase($month_number, $leap_year) { 99 static $translated_month_names; 100 101 if ($translated_month_names === null) { 102 $translated_month_names = array( 103 0 => '', 104 1 => /* I18N: a month in the French republican calendar */ I18N::translateContext('LOCATIVE', 'Vendémiaire'), 105 2 => /* I18N: a month in the French republican calendar */ I18N::translateContext('LOCATIVE', 'Brumaire'), 106 3 => /* I18N: a month in the French republican calendar */ I18N::translateContext('LOCATIVE', 'Frimaire'), 107 4 => /* I18N: a month in the French republican calendar */ I18N::translateContext('LOCATIVE', 'Nivôse'), 108 5 => /* I18N: a month in the French republican calendar */ I18N::translateContext('LOCATIVE', 'Pluviôse'), 109 6 => /* I18N: a month in the French republican calendar */ I18N::translateContext('LOCATIVE', 'Ventôse'), 110 7 => /* I18N: a month in the French republican calendar */ I18N::translateContext('LOCATIVE', 'Germinal'), 111 8 => /* I18N: a month in the French republican calendar */ I18N::translateContext('LOCATIVE', 'Floréal'), 112 9 => /* I18N: a month in the French republican calendar */ I18N::translateContext('LOCATIVE', 'Prairial'), 113 10 => /* I18N: a month in the French republican calendar */ I18N::translateContext('LOCATIVE', 'Messidor'), 114 11 => /* I18N: a month in the French republican calendar */ I18N::translateContext('LOCATIVE', 'Thermidor'), 115 12 => /* I18N: a month in the French republican calendar */ I18N::translateContext('LOCATIVE', 'Fructidor'), 116 13 => /* I18N: a month in the French republican calendar */ I18N::translateContext('LOCATIVE', 'jours complémentaires'), 117 ); 118 } 119 120 return $translated_month_names[$month_number]; 121 } 122 123 /** {@inheritdoc} */ 124 static function monthNameInstrumentalCase($month_number, $leap_year) { 125 static $translated_month_names; 126 127 if ($translated_month_names === null) { 128 $translated_month_names = array( 129 0 => '', 130 1 => /* I18N: a month in the French republican calendar */ I18N::translateContext('INSTRUMENTAL', 'Vendémiaire'), 131 2 => /* I18N: a month in the French republican calendar */ I18N::translateContext('INSTRUMENTAL', 'Brumaire'), 132 3 => /* I18N: a month in the French republican calendar */ I18N::translateContext('INSTRUMENTAL', 'Frimaire'), 133 4 => /* I18N: a month in the French republican calendar */ I18N::translateContext('INSTRUMENTAL', 'Nivôse'), 134 5 => /* I18N: a month in the French republican calendar */ I18N::translateContext('INSTRUMENTAL', 'Pluviôse'), 135 6 => /* I18N: a month in the French republican calendar */ I18N::translateContext('INSTRUMENTAL', 'Ventôse'), 136 7 => /* I18N: a month in the French republican calendar */ I18N::translateContext('INSTRUMENTAL', 'Germinal'), 137 8 => /* I18N: a month in the French republican calendar */ I18N::translateContext('INSTRUMENTAL', 'Floréal'), 138 9 => /* I18N: a month in the French republican calendar */ I18N::translateContext('INSTRUMENTAL', 'Prairial'), 139 10 => /* I18N: a month in the French republican calendar */ I18N::translateContext('INSTRUMENTAL', 'Messidor'), 140 11 => /* I18N: a month in the French republican calendar */ I18N::translateContext('INSTRUMENTAL', 'Thermidor'), 141 12 => /* I18N: a month in the French republican calendar */ I18N::translateContext('INSTRUMENTAL', 'Fructidor'), 142 13 => /* I18N: a month in the French republican calendar */ I18N::translateContext('INSTRUMENTAL', 'jours complémentaires'), 143 ); 144 } 145 146 return $translated_month_names[$month_number]; 147 } 148 149 /** {@inheritdoc} */ 150 protected static function monthNameAbbreviated($month_number, $leap_year) { 151 return self::monthNameNominativeCase($month_number, $leap_year); 152 } 153 154 /** {@inheritdoc} */ 155 public static function dayNames($day_number) { 156 static $translated_day_names; 157 158 if ($translated_day_names === null) { 159 $translated_day_names = array( 160 0 => /* I18N: a day in the French republican calendar */ I18N::translate('Primidi'), 161 1 => /* I18N: a day in the French republican calendar */ I18N::translate('Duodi'), 162 2 => /* I18N: a day in the French republican calendar */ I18N::translate('Tridi'), 163 3 => /* I18N: a day in the French republican calendar */ I18N::translate('Quartidi'), 164 4 => /* I18N: a day in the French republican calendar */ I18N::translate('Quintidi'), 165 5 => /* I18N: a day in the French republican calendar */ I18N::translate('Sextidi'), 166 6 => /* I18N: a day in the French republican calendar */ I18N::translate('Septidi'), 167 7 => /* I18N: a day in the French republican calendar */ I18N::translate('Octidi'), 168 8 => /* I18N: a day in the French republican calendar */ I18N::translate('Nonidi'), 169 9 => /* I18N: a day in the French republican calendar */ I18N::translate('Decidi'), 170 ); 171 } 172 173 return $translated_day_names[$day_number]; 174 } 175 176 /** {@inheritdoc} */ 177 protected static function dayNamesAbbreviated($day_number) { 178 return self::dayNames($day_number); 179 } 180 181 /** {@inheritdoc} */ 182 protected function formatLongYear() { 183 return $this->numberToRomanNumerals($this->y); 184 } 185} 186