summaryrefslogtreecommitdiff
path: root/app/Date/FrenchDate.php
blob: 90c907a06f89b0a1e7a12c608f89487636a53f08 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
<?php
namespace Fisharebest\Webtrees;

/**
 * webtrees: online genealogy
 * Copyright (C) 2015 webtrees development team
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 * You should have received a copy of the GNU General Public License
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
 */

use Fisharebest\ExtCalendar\FrenchCalendar;

/**
 * Class FrenchDate - Definitions for the French Republican calendar
 */
class FrenchDate extends CalendarDate {
	const CALENDAR_ESCAPE = '@#DFRENCH R@';
	const MONTHS_IN_YEAR = 13;
	const CAL_START_JD = 2375840; // 22 SEP 1792 = 01 VEND 0001
	const CAL_END_JD = 2380687; // 31 DEC 1805 = 10 NIVO 0014
	const DAYS_IN_WEEK = 10; // A metric week of 10 unimaginatively named days.

	/** {@inheritdoc} */
	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);

	/** {@inheritdoc} */
	public function __construct($date) {
		$this->calendar = new FrenchCalendar;
		parent::__construct($date);
	}

	/** {@inheritdoc} */
	public static function calendarName() {
		return /* I18N: The French calendar */ I18N::translate('French');
	}

	/** {@inheritdoc} */
	public static function monthNameNominativeCase($month_number, $leap_year) {
		static $translated_month_names;

		if ($translated_month_names === null) {
			$translated_month_names = array(
				0  => '',
				1  => /* I18N: a month in the French republican calendar */ I18N::translate_c('NOMINATIVE', 'Vendémiaire'),
				2  => /* I18N: a month in the French republican calendar */ I18N::translate_c('NOMINATIVE', 'Brumaire'),
				3  => /* I18N: a month in the French republican calendar */ I18N::translate_c('NOMINATIVE', 'Frimaire'),
				4  => /* I18N: a month in the French republican calendar */ I18N::translate_c('NOMINATIVE', 'Nivôse'),
				5  => /* I18N: a month in the French republican calendar */ I18N::translate_c('NOMINATIVE', 'Pluviôse'),
				6  => /* I18N: a month in the French republican calendar */ I18N::translate_c('NOMINATIVE', 'Ventôse'),
				7  => /* I18N: a month in the French republican calendar */ I18N::translate_c('NOMINATIVE', 'Germinal'),
				8  => /* I18N: a month in the French republican calendar */ I18N::translate_c('NOMINATIVE', 'Floréal'),
				9  => /* I18N: a month in the French republican calendar */ I18N::translate_c('NOMINATIVE', 'Prairial'),
				10 => /* I18N: a month in the French republican calendar */ I18N::translate_c('NOMINATIVE', 'Messidor'),
				11 => /* I18N: a month in the French republican calendar */ I18N::translate_c('NOMINATIVE', 'Thermidor'),
				12 => /* I18N: a month in the French republican calendar */ I18N::translate_c('NOMINATIVE', 'Fructidor'),
				13 => /* I18N: a month in the French republican calendar */ I18N::translate_c('NOMINATIVE', 'jours complémentaires'),
			);
		}

		return $translated_month_names[$month_number];
	}

	/** {@inheritdoc} */
	static function monthNameGenitiveCase($month_number, $leap_year) {
		static $translated_month_names;

		if ($translated_month_names === null) {
			$translated_month_names = array(
				0  => '',
				1  => /* I18N: a month in the French republican calendar */ I18N::translate_c('GENITIVE', 'Vendémiaire'),
				2  => /* I18N: a month in the French republican calendar */ I18N::translate_c('GENITIVE', 'Brumaire'),
				3  => /* I18N: a month in the French republican calendar */ I18N::translate_c('GENITIVE', 'Frimaire'),
				4  => /* I18N: a month in the French republican calendar */ I18N::translate_c('GENITIVE', 'Nivôse'),
				5  => /* I18N: a month in the French republican calendar */ I18N::translate_c('GENITIVE', 'Pluviôse'),
				6  => /* I18N: a month in the French republican calendar */ I18N::translate_c('GENITIVE', 'Ventôse'),
				7  => /* I18N: a month in the French republican calendar */ I18N::translate_c('GENITIVE', 'Germinal'),
				8  => /* I18N: a month in the French republican calendar */ I18N::translate_c('GENITIVE', 'Floréal'),
				9  => /* I18N: a month in the French republican calendar */ I18N::translate_c('GENITIVE', 'Prairial'),
				10 => /* I18N: a month in the French republican calendar */ I18N::translate_c('GENITIVE', 'Messidor'),
				11 => /* I18N: a month in the French republican calendar */ I18N::translate_c('GENITIVE', 'Thermidor'),
				12 => /* I18N: a month in the French republican calendar */ I18N::translate_c('GENITIVE', 'Fructidor'),
				13 => /* I18N: a month in the French republican calendar */ I18N::translate_c('GENITIVE', 'jours complémentaires'),
			);
		}

		return $translated_month_names[$month_number];
	}

	/** {@inheritdoc} */
	static function monthNameLocativeCase($month_number, $leap_year) {
		static $translated_month_names;

		if ($translated_month_names === null) {
			$translated_month_names = array(
				0  => '',
				1  => /* I18N: a month in the French republican calendar */ I18N::translate_c('LOCATIVE', 'Vendémiaire'),
				2  => /* I18N: a month in the French republican calendar */ I18N::translate_c('LOCATIVE', 'Brumaire'),
				3  => /* I18N: a month in the French republican calendar */ I18N::translate_c('LOCATIVE', 'Frimaire'),
				4  => /* I18N: a month in the French republican calendar */ I18N::translate_c('LOCATIVE', 'Nivôse'),
				5  => /* I18N: a month in the French republican calendar */ I18N::translate_c('LOCATIVE', 'Pluviôse'),
				6  => /* I18N: a month in the French republican calendar */ I18N::translate_c('LOCATIVE', 'Ventôse'),
				7  => /* I18N: a month in the French republican calendar */ I18N::translate_c('LOCATIVE', 'Germinal'),
				8  => /* I18N: a month in the French republican calendar */ I18N::translate_c('LOCATIVE', 'Floréal'),
				9  => /* I18N: a month in the French republican calendar */ I18N::translate_c('LOCATIVE', 'Prairial'),
				10 => /* I18N: a month in the French republican calendar */ I18N::translate_c('LOCATIVE', 'Messidor'),
				11 => /* I18N: a month in the French republican calendar */ I18N::translate_c('LOCATIVE', 'Thermidor'),
				12 => /* I18N: a month in the French republican calendar */ I18N::translate_c('LOCATIVE', 'Fructidor'),
				13 => /* I18N: a month in the French republican calendar */ I18N::translate_c('LOCATIVE', 'jours complémentaires'),
			);
		}

		return $translated_month_names[$month_number];
	}

	/** {@inheritdoc} */
	static function monthNameInstrumentalCase($month_number, $leap_year) {
		static $translated_month_names;

		if ($translated_month_names === null) {
			$translated_month_names = array(
				0  => '',
				1  => /* I18N: a month in the French republican calendar */ I18N::translate_c('INSTRUMENTAL', 'Vendémiaire'),
				2  => /* I18N: a month in the French republican calendar */ I18N::translate_c('INSTRUMENTAL', 'Brumaire'),
				3  => /* I18N: a month in the French republican calendar */ I18N::translate_c('INSTRUMENTAL', 'Frimaire'),
				4  => /* I18N: a month in the French republican calendar */ I18N::translate_c('INSTRUMENTAL', 'Nivôse'),
				5  => /* I18N: a month in the French republican calendar */ I18N::translate_c('INSTRUMENTAL', 'Pluviôse'),
				6  => /* I18N: a month in the French republican calendar */ I18N::translate_c('INSTRUMENTAL', 'Ventôse'),
				7  => /* I18N: a month in the French republican calendar */ I18N::translate_c('INSTRUMENTAL', 'Germinal'),
				8  => /* I18N: a month in the French republican calendar */ I18N::translate_c('INSTRUMENTAL', 'Floréal'),
				9  => /* I18N: a month in the French republican calendar */ I18N::translate_c('INSTRUMENTAL', 'Prairial'),
				10 => /* I18N: a month in the French republican calendar */ I18N::translate_c('INSTRUMENTAL', 'Messidor'),
				11 => /* I18N: a month in the French republican calendar */ I18N::translate_c('INSTRUMENTAL', 'Thermidor'),
				12 => /* I18N: a month in the French republican calendar */ I18N::translate_c('INSTRUMENTAL', 'Fructidor'),
				13 => /* I18N: a month in the French republican calendar */ I18N::translate_c('INSTRUMENTAL', 'jours complémentaires'),
			);
		}

		return $translated_month_names[$month_number];
	}

	/** {@inheritdoc} */
	protected static function monthNameAbbreviated($month_number, $leap_year) {
		return self::monthNameNominativeCase($month_number, $leap_year);
	}

	/** {@inheritdoc} */
	public static function dayNames($day_number) {
		static $translated_day_names;

		if ($translated_day_names === null) {
			$translated_day_names = array(
				0  => /* I18N: a day in the French republican calendar */ I18N::translate('Primidi'),
				1  => /* I18N: a day in the French republican calendar */ I18N::translate('Duodi'),
				2  => /* I18N: a day in the French republican calendar */ I18N::translate('Tridi'),
				3  => /* I18N: a day in the French republican calendar */ I18N::translate('Quartidi'),
				4  => /* I18N: a day in the French republican calendar */ I18N::translate('Quintidi'),
				5  => /* I18N: a day in the French republican calendar */ I18N::translate('Sextidi'),
				6  => /* I18N: a day in the French republican calendar */ I18N::translate('Septidi'),
				7  => /* I18N: a day in the French republican calendar */ I18N::translate('Octidi'),
				8  => /* I18N: a day in the French republican calendar */ I18N::translate('Nonidi'),
				9  => /* I18N: a day in the French republican calendar */ I18N::translate('Decidi'),
			);
		}

		return $translated_day_names[$day_number];
	}

	/** {@inheritdoc} */
	protected static function dayNamesAbbreviated($day_number) {
		return self::dayNames($day_number);
	}

	/** {@inheritdoc} */
	protected function formatLongYear() {
		return $this->numberToRomanNumerals($this->y);
	}
}