14a83f5d7SGreg Roach<?php 23976b470SGreg Roach 34a83f5d7SGreg Roach/** 44a83f5d7SGreg Roach * webtrees: online genealogy 5*d11be702SGreg Roach * Copyright (C) 2023 webtrees development team 64a83f5d7SGreg Roach * This program is free software: you can redistribute it and/or modify 74a83f5d7SGreg Roach * it under the terms of the GNU General Public License as published by 84a83f5d7SGreg Roach * the Free Software Foundation, either version 3 of the License, or 94a83f5d7SGreg Roach * (at your option) any later version. 104a83f5d7SGreg Roach * This program is distributed in the hope that it will be useful, 114a83f5d7SGreg Roach * but WITHOUT ANY WARRANTY; without even the implied warranty of 124a83f5d7SGreg Roach * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 134a83f5d7SGreg Roach * GNU General Public License for more details. 144a83f5d7SGreg Roach * You should have received a copy of the GNU General Public License 1589f7189bSGreg Roach * along with this program. If not, see <https://www.gnu.org/licenses/>. 164a83f5d7SGreg Roach */ 17fcfa147eSGreg Roach 184a83f5d7SGreg Roachdeclare(strict_types=1); 194a83f5d7SGreg Roach 204a83f5d7SGreg Roachnamespace Fisharebest\Webtrees\Date; 214a83f5d7SGreg Roach 224a83f5d7SGreg Roachuse Fisharebest\Webtrees\I18N; 234a83f5d7SGreg Roach 244a83f5d7SGreg Roach/** 254a83f5d7SGreg Roach * Common definitions for Gregorian and Julian dates. 264a83f5d7SGreg Roach */ 274a83f5d7SGreg Roachabstract class AbstractGregorianJulianDate extends AbstractCalendarDate 284a83f5d7SGreg Roach{ 294a83f5d7SGreg Roach // Convert GEDCOM month names to month numbers 3016d6367aSGreg Roach protected const MONTH_ABBREVIATIONS = [ 314a83f5d7SGreg Roach '' => 0, 324a83f5d7SGreg Roach 'JAN' => 1, 334a83f5d7SGreg Roach 'FEB' => 2, 344a83f5d7SGreg Roach 'MAR' => 3, 354a83f5d7SGreg Roach 'APR' => 4, 364a83f5d7SGreg Roach 'MAY' => 5, 374a83f5d7SGreg Roach 'JUN' => 6, 384a83f5d7SGreg Roach 'JUL' => 7, 394a83f5d7SGreg Roach 'AUG' => 8, 404a83f5d7SGreg Roach 'SEP' => 9, 414a83f5d7SGreg Roach 'OCT' => 10, 424a83f5d7SGreg Roach 'NOV' => 11, 434a83f5d7SGreg Roach 'DEC' => 12, 444a83f5d7SGreg Roach ]; 454a83f5d7SGreg Roach 46d8809d62SGreg Roach protected const MONTH_TO_NUMBER = [ 47d8809d62SGreg Roach 'JAN' => 1, 48d8809d62SGreg Roach 'FEB' => 2, 49d8809d62SGreg Roach 'MAR' => 3, 50d8809d62SGreg Roach 'APR' => 4, 51d8809d62SGreg Roach 'MAY' => 5, 52d8809d62SGreg Roach 'JUN' => 6, 53d8809d62SGreg Roach 'JUL' => 7, 54d8809d62SGreg Roach 'AUG' => 8, 55d8809d62SGreg Roach 'SEP' => 9, 56d8809d62SGreg Roach 'OCT' => 10, 57d8809d62SGreg Roach 'NOV' => 11, 58d8809d62SGreg Roach 'DEC' => 12, 59d8809d62SGreg Roach ]; 60d8809d62SGreg Roach 61d8809d62SGreg Roach protected const NUMBER_TO_MONTH = [ 62d8809d62SGreg Roach 1 => 'JAN', 63d8809d62SGreg Roach 2 => 'FEB', 64d8809d62SGreg Roach 3 => 'MAR', 65d8809d62SGreg Roach 4 => 'APR', 66d8809d62SGreg Roach 5 => 'MAY', 67d8809d62SGreg Roach 6 => 'JUN', 68d8809d62SGreg Roach 7 => 'JUL', 69d8809d62SGreg Roach 8 => 'AUG', 70d8809d62SGreg Roach 9 => 'SEP', 71d8809d62SGreg Roach 10 => 'OCT', 72d8809d62SGreg Roach 11 => 'NOV', 73d8809d62SGreg Roach 12 => 'DEC', 74d8809d62SGreg Roach ]; 75d8809d62SGreg Roach 764a83f5d7SGreg Roach /** 774a83f5d7SGreg Roach * Full month name in nominative case. 784a83f5d7SGreg Roach * 794a83f5d7SGreg Roach * We put these in the base class, to save duplicating it in the Julian and Gregorian calendars. 804a83f5d7SGreg Roach * 817bb2eb25SGreg Roach * @param int $month 824a83f5d7SGreg Roach * @param bool $leap_year Some calendars use leap months 834a83f5d7SGreg Roach * 844a83f5d7SGreg Roach * @return string 854a83f5d7SGreg Roach */ 867bb2eb25SGreg Roach protected function monthNameNominativeCase(int $month, bool $leap_year): string 874a83f5d7SGreg Roach { 884a83f5d7SGreg Roach static $translated_month_names; 894a83f5d7SGreg Roach 904a83f5d7SGreg Roach if ($translated_month_names === null) { 914a83f5d7SGreg Roach $translated_month_names = [ 924a83f5d7SGreg Roach 0 => '', 934a83f5d7SGreg Roach 1 => I18N::translateContext('NOMINATIVE', 'January'), 944a83f5d7SGreg Roach 2 => I18N::translateContext('NOMINATIVE', 'February'), 954a83f5d7SGreg Roach 3 => I18N::translateContext('NOMINATIVE', 'March'), 964a83f5d7SGreg Roach 4 => I18N::translateContext('NOMINATIVE', 'April'), 974a83f5d7SGreg Roach 5 => I18N::translateContext('NOMINATIVE', 'May'), 984a83f5d7SGreg Roach 6 => I18N::translateContext('NOMINATIVE', 'June'), 994a83f5d7SGreg Roach 7 => I18N::translateContext('NOMINATIVE', 'July'), 1004a83f5d7SGreg Roach 8 => I18N::translateContext('NOMINATIVE', 'August'), 1014a83f5d7SGreg Roach 9 => I18N::translateContext('NOMINATIVE', 'September'), 1024a83f5d7SGreg Roach 10 => I18N::translateContext('NOMINATIVE', 'October'), 1034a83f5d7SGreg Roach 11 => I18N::translateContext('NOMINATIVE', 'November'), 1044a83f5d7SGreg Roach 12 => I18N::translateContext('NOMINATIVE', 'December'), 1054a83f5d7SGreg Roach ]; 1064a83f5d7SGreg Roach } 1074a83f5d7SGreg Roach 1087bb2eb25SGreg Roach return $translated_month_names[$month]; 1094a83f5d7SGreg Roach } 1104a83f5d7SGreg Roach 1114a83f5d7SGreg Roach /** 1124a83f5d7SGreg Roach * Full month name in genitive case. 1134a83f5d7SGreg Roach * 1144a83f5d7SGreg Roach * We put these in the base class, to save duplicating it in the Julian and Gregorian calendars. 1154a83f5d7SGreg Roach * 1167bb2eb25SGreg Roach * @param int $month 1174a83f5d7SGreg Roach * @param bool $leap_year Some calendars use leap months 1184a83f5d7SGreg Roach * 1194a83f5d7SGreg Roach * @return string 1204a83f5d7SGreg Roach */ 1217bb2eb25SGreg Roach protected function monthNameGenitiveCase(int $month, bool $leap_year): string 1224a83f5d7SGreg Roach { 1234a83f5d7SGreg Roach static $translated_month_names; 1244a83f5d7SGreg Roach 1254a83f5d7SGreg Roach if ($translated_month_names === null) { 1264a83f5d7SGreg Roach $translated_month_names = [ 1274a83f5d7SGreg Roach 0 => '', 1284a83f5d7SGreg Roach 1 => I18N::translateContext('GENITIVE', 'January'), 1294a83f5d7SGreg Roach 2 => I18N::translateContext('GENITIVE', 'February'), 1304a83f5d7SGreg Roach 3 => I18N::translateContext('GENITIVE', 'March'), 1314a83f5d7SGreg Roach 4 => I18N::translateContext('GENITIVE', 'April'), 1324a83f5d7SGreg Roach 5 => I18N::translateContext('GENITIVE', 'May'), 1334a83f5d7SGreg Roach 6 => I18N::translateContext('GENITIVE', 'June'), 1344a83f5d7SGreg Roach 7 => I18N::translateContext('GENITIVE', 'July'), 1354a83f5d7SGreg Roach 8 => I18N::translateContext('GENITIVE', 'August'), 1364a83f5d7SGreg Roach 9 => I18N::translateContext('GENITIVE', 'September'), 1374a83f5d7SGreg Roach 10 => I18N::translateContext('GENITIVE', 'October'), 1384a83f5d7SGreg Roach 11 => I18N::translateContext('GENITIVE', 'November'), 1394a83f5d7SGreg Roach 12 => I18N::translateContext('GENITIVE', 'December'), 1404a83f5d7SGreg Roach ]; 1414a83f5d7SGreg Roach } 1424a83f5d7SGreg Roach 1437bb2eb25SGreg Roach return $translated_month_names[$month]; 1444a83f5d7SGreg Roach } 1454a83f5d7SGreg Roach 1464a83f5d7SGreg Roach /** 1474a83f5d7SGreg Roach * Full month name in locative case. 1484a83f5d7SGreg Roach * 1494a83f5d7SGreg Roach * We put these in the base class, to save duplicating it in the Julian and Gregorian calendars. 1504a83f5d7SGreg Roach * 1517bb2eb25SGreg Roach * @param int $month 1524a83f5d7SGreg Roach * @param bool $leap_year Some calendars use leap months 1534a83f5d7SGreg Roach * 1544a83f5d7SGreg Roach * @return string 1554a83f5d7SGreg Roach */ 1567bb2eb25SGreg Roach protected function monthNameLocativeCase(int $month, bool $leap_year): string 1574a83f5d7SGreg Roach { 1584a83f5d7SGreg Roach static $translated_month_names; 1594a83f5d7SGreg Roach 1604a83f5d7SGreg Roach if ($translated_month_names === null) { 1614a83f5d7SGreg Roach $translated_month_names = [ 1624a83f5d7SGreg Roach 0 => '', 1634a83f5d7SGreg Roach 1 => I18N::translateContext('LOCATIVE', 'January'), 1644a83f5d7SGreg Roach 2 => I18N::translateContext('LOCATIVE', 'February'), 1654a83f5d7SGreg Roach 3 => I18N::translateContext('LOCATIVE', 'March'), 1664a83f5d7SGreg Roach 4 => I18N::translateContext('LOCATIVE', 'April'), 1674a83f5d7SGreg Roach 5 => I18N::translateContext('LOCATIVE', 'May'), 1684a83f5d7SGreg Roach 6 => I18N::translateContext('LOCATIVE', 'June'), 1694a83f5d7SGreg Roach 7 => I18N::translateContext('LOCATIVE', 'July'), 1704a83f5d7SGreg Roach 8 => I18N::translateContext('LOCATIVE', 'August'), 1714a83f5d7SGreg Roach 9 => I18N::translateContext('LOCATIVE', 'September'), 1724a83f5d7SGreg Roach 10 => I18N::translateContext('LOCATIVE', 'October'), 1734a83f5d7SGreg Roach 11 => I18N::translateContext('LOCATIVE', 'November'), 1744a83f5d7SGreg Roach 12 => I18N::translateContext('LOCATIVE', 'December'), 1754a83f5d7SGreg Roach ]; 1764a83f5d7SGreg Roach } 1774a83f5d7SGreg Roach 1787bb2eb25SGreg Roach return $translated_month_names[$month]; 1794a83f5d7SGreg Roach } 1804a83f5d7SGreg Roach 1814a83f5d7SGreg Roach /** 1824a83f5d7SGreg Roach * Full month name in instrumental case. 1834a83f5d7SGreg Roach * 1844a83f5d7SGreg Roach * We put these in the base class, to save duplicating it in the Julian and Gregorian calendars. 1854a83f5d7SGreg Roach * 1867bb2eb25SGreg Roach * @param int $month 1874a83f5d7SGreg Roach * @param bool $leap_year Some calendars use leap months 1884a83f5d7SGreg Roach * 1894a83f5d7SGreg Roach * @return string 1904a83f5d7SGreg Roach */ 1917bb2eb25SGreg Roach protected function monthNameInstrumentalCase(int $month, bool $leap_year): string 1924a83f5d7SGreg Roach { 1934a83f5d7SGreg Roach static $translated_month_names; 1944a83f5d7SGreg Roach 1954a83f5d7SGreg Roach if ($translated_month_names === null) { 1964a83f5d7SGreg Roach $translated_month_names = [ 1974a83f5d7SGreg Roach 0 => '', 1984a83f5d7SGreg Roach 1 => I18N::translateContext('INSTRUMENTAL', 'January'), 1994a83f5d7SGreg Roach 2 => I18N::translateContext('INSTRUMENTAL', 'February'), 2004a83f5d7SGreg Roach 3 => I18N::translateContext('INSTRUMENTAL', 'March'), 2014a83f5d7SGreg Roach 4 => I18N::translateContext('INSTRUMENTAL', 'April'), 2024a83f5d7SGreg Roach 5 => I18N::translateContext('INSTRUMENTAL', 'May'), 2034a83f5d7SGreg Roach 6 => I18N::translateContext('INSTRUMENTAL', 'June'), 2044a83f5d7SGreg Roach 7 => I18N::translateContext('INSTRUMENTAL', 'July'), 2054a83f5d7SGreg Roach 8 => I18N::translateContext('INSTRUMENTAL', 'August'), 2064a83f5d7SGreg Roach 9 => I18N::translateContext('INSTRUMENTAL', 'September'), 2074a83f5d7SGreg Roach 10 => I18N::translateContext('INSTRUMENTAL', 'October'), 2084a83f5d7SGreg Roach 11 => I18N::translateContext('INSTRUMENTAL', 'November'), 2094a83f5d7SGreg Roach 12 => I18N::translateContext('INSTRUMENTAL', 'December'), 2104a83f5d7SGreg Roach ]; 2114a83f5d7SGreg Roach } 2124a83f5d7SGreg Roach 2137bb2eb25SGreg Roach return $translated_month_names[$month]; 2144a83f5d7SGreg Roach } 2154a83f5d7SGreg Roach 2164a83f5d7SGreg Roach /** 2174a83f5d7SGreg Roach * Abbreviated month name 2184a83f5d7SGreg Roach * 2197bb2eb25SGreg Roach * @param int $month 2204a83f5d7SGreg Roach * @param bool $leap_year Some calendars use leap months 2214a83f5d7SGreg Roach * 2224a83f5d7SGreg Roach * @return string 2234a83f5d7SGreg Roach */ 2247bb2eb25SGreg Roach protected function monthNameAbbreviated(int $month, bool $leap_year): string 2254a83f5d7SGreg Roach { 2264a83f5d7SGreg Roach static $translated_month_names; 2274a83f5d7SGreg Roach 2284a83f5d7SGreg Roach if ($translated_month_names === null) { 2294a83f5d7SGreg Roach $translated_month_names = [ 2304a83f5d7SGreg Roach 0 => '', 2314a83f5d7SGreg Roach 1 => I18N::translateContext('Abbreviation for January', 'Jan'), 2324a83f5d7SGreg Roach 2 => I18N::translateContext('Abbreviation for February', 'Feb'), 2334a83f5d7SGreg Roach 3 => I18N::translateContext('Abbreviation for March', 'Mar'), 2344a83f5d7SGreg Roach 4 => I18N::translateContext('Abbreviation for April', 'Apr'), 2354a83f5d7SGreg Roach 5 => I18N::translateContext('Abbreviation for May', 'May'), 2364a83f5d7SGreg Roach 6 => I18N::translateContext('Abbreviation for June', 'Jun'), 2374a83f5d7SGreg Roach 7 => I18N::translateContext('Abbreviation for July', 'Jul'), 2384a83f5d7SGreg Roach 8 => I18N::translateContext('Abbreviation for August', 'Aug'), 2394a83f5d7SGreg Roach 9 => I18N::translateContext('Abbreviation for September', 'Sep'), 2404a83f5d7SGreg Roach 10 => I18N::translateContext('Abbreviation for October', 'Oct'), 2414a83f5d7SGreg Roach 11 => I18N::translateContext('Abbreviation for November', 'Nov'), 2424a83f5d7SGreg Roach 12 => I18N::translateContext('Abbreviation for December', 'Dec'), 2434a83f5d7SGreg Roach ]; 2444a83f5d7SGreg Roach } 2454a83f5d7SGreg Roach 2467bb2eb25SGreg Roach return $translated_month_names[$month]; 2474a83f5d7SGreg Roach } 2484a83f5d7SGreg Roach} 249