. */ declare(strict_types=1); namespace Fisharebest\Webtrees\Date; use Fisharebest\Webtrees\I18N; /** * Common definitions for Gregorian and Julian dates. */ abstract class AbstractGregorianJulianDate extends AbstractCalendarDate { // Convert GEDCOM month names to month numbers const MONTH_ABBREVIATIONS = [ '' => 0, 'JAN' => 1, 'FEB' => 2, 'MAR' => 3, 'APR' => 4, 'MAY' => 5, 'JUN' => 6, 'JUL' => 7, 'AUG' => 8, 'SEP' => 9, 'OCT' => 10, 'NOV' => 11, 'DEC' => 12, ]; /** * Full month name in nominative case. * * We put these in the base class, to save duplicating it in the Julian and Gregorian calendars. * * @param int $month * @param bool $leap_year Some calendars use leap months * * @return string */ protected function monthNameNominativeCase(int $month, bool $leap_year): string { static $translated_month_names; if ($translated_month_names === null) { $translated_month_names = [ 0 => '', 1 => I18N::translateContext('NOMINATIVE', 'January'), 2 => I18N::translateContext('NOMINATIVE', 'February'), 3 => I18N::translateContext('NOMINATIVE', 'March'), 4 => I18N::translateContext('NOMINATIVE', 'April'), 5 => I18N::translateContext('NOMINATIVE', 'May'), 6 => I18N::translateContext('NOMINATIVE', 'June'), 7 => I18N::translateContext('NOMINATIVE', 'July'), 8 => I18N::translateContext('NOMINATIVE', 'August'), 9 => I18N::translateContext('NOMINATIVE', 'September'), 10 => I18N::translateContext('NOMINATIVE', 'October'), 11 => I18N::translateContext('NOMINATIVE', 'November'), 12 => I18N::translateContext('NOMINATIVE', 'December'), ]; } return $translated_month_names[$month]; } /** * Full month name in genitive case. * * We put these in the base class, to save duplicating it in the Julian and Gregorian calendars. * * @param int $month * @param bool $leap_year Some calendars use leap months * * @return string */ protected function monthNameGenitiveCase(int $month, bool $leap_year): string { static $translated_month_names; if ($translated_month_names === null) { $translated_month_names = [ 0 => '', 1 => I18N::translateContext('GENITIVE', 'January'), 2 => I18N::translateContext('GENITIVE', 'February'), 3 => I18N::translateContext('GENITIVE', 'March'), 4 => I18N::translateContext('GENITIVE', 'April'), 5 => I18N::translateContext('GENITIVE', 'May'), 6 => I18N::translateContext('GENITIVE', 'June'), 7 => I18N::translateContext('GENITIVE', 'July'), 8 => I18N::translateContext('GENITIVE', 'August'), 9 => I18N::translateContext('GENITIVE', 'September'), 10 => I18N::translateContext('GENITIVE', 'October'), 11 => I18N::translateContext('GENITIVE', 'November'), 12 => I18N::translateContext('GENITIVE', 'December'), ]; } return $translated_month_names[$month]; } /** * Full month name in locative case. * * We put these in the base class, to save duplicating it in the Julian and Gregorian calendars. * * @param int $month * @param bool $leap_year Some calendars use leap months * * @return string */ protected function monthNameLocativeCase(int $month, bool $leap_year): string { static $translated_month_names; if ($translated_month_names === null) { $translated_month_names = [ 0 => '', 1 => I18N::translateContext('LOCATIVE', 'January'), 2 => I18N::translateContext('LOCATIVE', 'February'), 3 => I18N::translateContext('LOCATIVE', 'March'), 4 => I18N::translateContext('LOCATIVE', 'April'), 5 => I18N::translateContext('LOCATIVE', 'May'), 6 => I18N::translateContext('LOCATIVE', 'June'), 7 => I18N::translateContext('LOCATIVE', 'July'), 8 => I18N::translateContext('LOCATIVE', 'August'), 9 => I18N::translateContext('LOCATIVE', 'September'), 10 => I18N::translateContext('LOCATIVE', 'October'), 11 => I18N::translateContext('LOCATIVE', 'November'), 12 => I18N::translateContext('LOCATIVE', 'December'), ]; } return $translated_month_names[$month]; } /** * Full month name in instrumental case. * * We put these in the base class, to save duplicating it in the Julian and Gregorian calendars. * * @param int $month * @param bool $leap_year Some calendars use leap months * * @return string */ protected function monthNameInstrumentalCase(int $month, bool $leap_year): string { static $translated_month_names; if ($translated_month_names === null) { $translated_month_names = [ 0 => '', 1 => I18N::translateContext('INSTRUMENTAL', 'January'), 2 => I18N::translateContext('INSTRUMENTAL', 'February'), 3 => I18N::translateContext('INSTRUMENTAL', 'March'), 4 => I18N::translateContext('INSTRUMENTAL', 'April'), 5 => I18N::translateContext('INSTRUMENTAL', 'May'), 6 => I18N::translateContext('INSTRUMENTAL', 'June'), 7 => I18N::translateContext('INSTRUMENTAL', 'July'), 8 => I18N::translateContext('INSTRUMENTAL', 'August'), 9 => I18N::translateContext('INSTRUMENTAL', 'September'), 10 => I18N::translateContext('INSTRUMENTAL', 'October'), 11 => I18N::translateContext('INSTRUMENTAL', 'November'), 12 => I18N::translateContext('INSTRUMENTAL', 'December'), ]; } return $translated_month_names[$month]; } /** * Abbreviated month name * * @param int $month * @param bool $leap_year Some calendars use leap months * * @return string */ protected function monthNameAbbreviated(int $month, bool $leap_year): string { static $translated_month_names; if ($translated_month_names === null) { $translated_month_names = [ 0 => '', 1 => I18N::translateContext('Abbreviation for January', 'Jan'), 2 => I18N::translateContext('Abbreviation for February', 'Feb'), 3 => I18N::translateContext('Abbreviation for March', 'Mar'), 4 => I18N::translateContext('Abbreviation for April', 'Apr'), 5 => I18N::translateContext('Abbreviation for May', 'May'), 6 => I18N::translateContext('Abbreviation for June', 'Jun'), 7 => I18N::translateContext('Abbreviation for July', 'Jul'), 8 => I18N::translateContext('Abbreviation for August', 'Aug'), 9 => I18N::translateContext('Abbreviation for September', 'Sep'), 10 => I18N::translateContext('Abbreviation for October', 'Oct'), 11 => I18N::translateContext('Abbreviation for November', 'Nov'), 12 => I18N::translateContext('Abbreviation for December', 'Dec'), ]; } return $translated_month_names[$month]; } }