From 2adcd8f9bfab7532a0aa5fa1c8a8cbcec210670d Mon Sep 17 00:00:00 2001 From: "John R. D'Orazio" Date: Sun, 24 Mar 2024 19:27:44 +0100 Subject: [PATCH] avoid defining year cycle for holy week and octave easter --- includes/FestivityCollection.php | 62 +++++++++++++++++++++++--------- includes/enums/LitSeason.php | 6 +++- 2 files changed, 51 insertions(+), 17 deletions(-) diff --git a/includes/FestivityCollection.php b/includes/FestivityCollection.php index 1b4ce265..f0ca9da1 100644 --- a/includes/FestivityCollection.php +++ b/includes/FestivityCollection.php @@ -296,21 +296,7 @@ private function inOrdinaryTime( LitDateTime $date ) : bool { public function setCyclesVigilsSeasons() { foreach( $this->festivities as $key => $festivity ) { - if ( self::DateIsNotSunday( $festivity->date ) && (int)$festivity->grade === LitGrade::WEEKDAY ) { - if( $this->inOrdinaryTime( $festivity->date ) ) { - $this->festivities[ $key ]->liturgicalYear = $this->T[ "YEAR" ] . " " . ( self::WEEKDAY_CYCLE[ ( $this->LitSettings->Year - 1 ) % 2 ] ); - } - } - //if we're dealing with a Sunday or a Solemnity or a Feast of the Lord, then we calculate the Sunday/Festive Cycle - else if( self::DateIsSunday( $festivity->date ) || (int)$festivity->grade > LitGrade::FEAST ) { - if ( $festivity->date < $this->festivities[ "Advent1" ]->date ) { - $this->festivities[ $key ]->liturgicalYear = $this->T[ "YEAR" ] . " " . ( self::SUNDAY_CYCLE[ ( $this->LitSettings->Year - 1 ) % 3 ] ); - } else if ( $festivity->date >= $this->festivities[ "Advent1" ]->date ) { - $this->festivities[ $key ]->liturgicalYear = $this->T[ "YEAR" ] . " " . ( self::SUNDAY_CYCLE[ $this->LitSettings->Year % 3 ] ); - } - $this->calculateVigilMass( $key, $festivity ); - } - + // DEFINE LITURGICAL SEASONS if( $festivity->date >= $this->festivities[ "Advent1" ]->date && $festivity->date < $this->festivities[ "Christmas" ]->date ) { $this->festivities[ $key ]->liturgicalSeason = LitSeason::ADVENT; } @@ -321,7 +307,7 @@ public function setCyclesVigilsSeasons() { $this->festivities[ $key ]->liturgicalSeason = LitSeason::LENT; } else if( $festivity->date > $this->festivities[ "HolyThurs" ]->date && $festivity->date < $this->festivities[ "Easter" ]->date ) { - //the Easter Triduum doesn't really count as either Lent or Easter + $this->festivities[ $key ]->liturgicalSeason = LitSeason::EASTER_TRIDUUM; } else if( $festivity->date >= $this->festivities[ "Easter" ]->date && $festivity->date <= $this->festivities[ "Pentecost" ]->date ) { $this->festivities[ $key ]->liturgicalSeason = LitSeason::EASTER; @@ -329,6 +315,26 @@ public function setCyclesVigilsSeasons() { else { $this->festivities[ $key ]->liturgicalSeason = LitSeason::ORDINARY_TIME; } + + // DEFINE YEAR CYCLES (except for Holy Week and Easter Octave) + if( $festivity->date <= $this->festivities[ "PalmSun" ]->date && $festivity->date >= $this->festivities[ "Easter2" ]->date ) { + if ( self::DateIsNotSunday( $festivity->date ) && (int)$festivity->grade === LitGrade::WEEKDAY ) { + if( $this->inOrdinaryTime( $festivity->date ) ) { + $this->festivities[ $key ]->liturgicalYear = $this->T[ "YEAR" ] . " " . ( self::WEEKDAY_CYCLE[ ( $this->LitSettings->Year - 1 ) % 2 ] ); + } + } + //if we're dealing with a Sunday or a Solemnity or a Feast of the Lord, then we calculate the Sunday/Festive Cycle + else if( self::DateIsSunday( $festivity->date ) || (int)$festivity->grade > LitGrade::FEAST ) { + if ( $festivity->date < $this->festivities[ "Advent1" ]->date ) { + $this->festivities[ $key ]->liturgicalYear = $this->T[ "YEAR" ] . " " . ( self::SUNDAY_CYCLE[ ( $this->LitSettings->Year - 1 ) % 3 ] ); + } else if ( $festivity->date >= $this->festivities[ "Advent1" ]->date ) { + $this->festivities[ $key ]->liturgicalYear = $this->T[ "YEAR" ] . " " . ( self::SUNDAY_CYCLE[ $this->LitSettings->Year % 3 ] ); + } + // DEFINE VIGIL MASSES + $this->calculateVigilMass( $key, $festivity ); + } + } + } } @@ -536,4 +542,28 @@ public static function psalterWeek( int $weekOfOrdinaryTimeOrSeason ) : int { return $weekOfOrdinaryTimeOrSeason % 4 === 0 ? 4 : $weekOfOrdinaryTimeOrSeason % 4; } + public function isAdventSeason( Festivity $festivity ) { + return $festivity->liturgicalSeason === LitSeason::ADVENT; + } + + public function isChristmasSeason( Festivity $festivity ) { + return $festivity->liturgicalSeason === LitSeason::CHRISTMAS; + } + + public function isLentSeason( Festivity $festivity ) { + return $festivity->liturgicalSeason === LitSeason::LENT; + } + + public function isEasterTriduum( Festivity $festivity ) { + return $festivity->liturgicalSeason === LitSeason::EASTER_TRIDUUM; + } + + public function isEasterSeason( Festivity $festivity ) { + return $festivity->liturgicalSeason === LitSeason::EASTER; + } + + public function isOrdinaryTime( Festivity $festivity ) { + return $festivity->liturgicalSeason === LitSeason::ORDINARY_TIME; + } + } diff --git a/includes/enums/LitSeason.php b/includes/enums/LitSeason.php index 0826d4ec..c5ab76d3 100644 --- a/includes/enums/LitSeason.php +++ b/includes/enums/LitSeason.php @@ -4,9 +4,10 @@ class LitSeason { const ADVENT = "ADVENT"; const CHRISTMAS = "CHRISTMAS"; const LENT = "LENT"; + const EASTER_TRIDUUM= "EASTER_TRIDUUM"; const EASTER = "EASTER"; const ORDINARY_TIME = "ORDINARY_TIME"; - public static array $values = [ "ADVENT", "CHRISTMAS", "LENT", "EASTER", "ORDINARY_TIME" ]; + public static array $values = [ "ADVENT", "CHRISTMAS", "LENT", "EASTER_TRIDUUM", "EASTER", "ORDINARY_TIME" ]; public static function isValid( string $value ) { return in_array( $value, self::$values ); @@ -23,6 +24,9 @@ public static function i18n( string $value, string $locale ) : string { case self::LENT: /**translators: context = liturgical season */ return $locale === LitLocale::LATIN ? 'Tempus Quadragesima' : _( "Lent" ); + case self::EASTER_TRIDUUM: + /**translators: context = liturgical season */ + return $locale === LitLocale::LATIN ? 'Triduum Paschale' : _( "Easter Triduum" ); case self::EASTER: /**translators: context = liturgical season */ return $locale === LitLocale::LATIN ? 'Tempus Paschale' : _( "Easter" );