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