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