Date-Lectionary
view release on metacpan or search on metacpan
lib/Date/Lectionary/Day.pm view on Meta::CPAN
}
catch {
confess "The XPATH expression to to query the cross reference database could not be compiled.";
};
my $altName;
try {
$altName = $lectionary->findvalue($compiled_xpath);
return $altName;
}
catch {
confess "An unpected error occured while querying the cross reference database.";
};
}
=head2 _determineAdvent
Private method that takes a Time::Piece date object to returns a Date::Advent object containing the dates for Advent of the current liturgical year.
=cut
sub _determineAdvent {
my $date = shift;
my $advent = undef;
try {
$advent = Date::Advent->new( date => $date );
return $advent;
}
catch {
confess "Could not calculate Advent for the given date [" . $date->ymd . "].";
};
}
=head2 _determineEaster
Private method that takes a four-digit representation of a Common Era year and calculates the date for Easter as a Time::Piece object.
=cut
sub _determineEaster {
my $easterYear = shift;
my $easter = undef;
try {
my ( $easterMonth, $easterDay ) = easter($easterYear);
$easter = Time::Piece->strptime( $easterYear . "-" . $easterMonth . "-" . $easterDay, "%Y-%m-%d" );
return $easter;
}
catch {
confess "Could not calculate Easter for the year [" . $easterYear . "]";
};
}
=head2 _determineFeasts
Private method that takes the Time::Piece date given at construction and determines if the date is one of many feasts in the liturgical calendar. Feasts are taken from the Anglican Church in North America's revision of the revised common lectionary.
=cut
sub _determineFeasts {
my $date = shift;
my $lectionary = shift;
my $yesterday = $date - ONE_DAY;
my $yesterdayName;
if ( $yesterday->wday == 1 ) {
$yesterdayName = _buildMoveableDays( $yesterday, $lectionary );
}
if ($yesterdayName) {
return (
commonName => $yesterdayName,
type => 'moveableFeast',
season => 'NaN'
);
}
my $fixedDayName = _buildFixedDays( $date, $lectionary );
if ($fixedDayName) {
return (
commonName => $fixedDayName->{commonName},
type => 'fixedFeast',
season => $fixedDayName->{season}
);
}
my $moveableDayName = _buildMoveableDays( $date, $lectionary );
if ( $moveableDayName && $date->wday != 1 ) {
return (
commonName => $moveableDayName,
type => 'moveableFeast',
season => 'NaN'
);
}
return ( commonName => undef, type => undef, season => 'NaN' );
}
=head2 _buildMoveableDays
Private method that takes the Time::Piece date given at construction and determines if the date is one of many moveable feasts in the liturgical calendar. Feasts are taken from the Anglican Church in North America's revision of the revised common le...
=cut
sub _buildMoveableDays {
my $date = shift;
my $lectionary = shift;
#Moveable holidays in January
if ( $date->mon == 1 ) {
if ( $date->mday == 18 && $lectionary eq 'acna' ) {
return "Confession of St. Peter";
}
if ( $date->mday == 25 && $lectionary eq 'acna' ) {
return "Conversion of St. Paul";
}
}
#Moveable holidays in February
elsif ( $date->mon == 2 ) {
if ( $date->mday == 2 ) {
return "The Presentation of Christ in the Temple";
}
if ( $date->mday == 24 && $lectionary eq 'acna' ) {
return "St. Matthias";
}
}
#Moveable holidays in March
elsif ( $date->mon == 3 ) {
if ( $date->mday == 19 && $lectionary eq 'acna' ) {
return "St. Joseph";
}
if ( $date->mday == 25 ) {
return "The Annunciation";
}
}
#Moveable holidays in April
elsif ( $date->mon == 4 ) {
if ( $date->mday == 25 && $lectionary eq 'acna' ) {
return "St. Mark";
}
}
#Moveable holidays in May
elsif ( $date->mon == 5 ) {
if ( $date->mday == 1 && $lectionary eq 'acna' ) {
return "St. Philip & St. James";
}
if ( $date->mday == 31 ) {
return "The Visitation";
}
}
#Moveable holidays in June
elsif ( $date->mon == 6 ) {
if ( $date->mday == 11 && $lectionary eq 'acna' ) {
return "St. Barnabas";
}
if ( $date->mday == 24 && $lectionary eq 'acna' ) {
lib/Date/Lectionary/Day.pm view on Meta::CPAN
if ( $date->mday == 15 && $lectionary eq 'acna' ) {
return "St. Mary the Virgin";
}
if ( $date->mday == 24 && $lectionary eq 'acna' ) {
return "St. Bartholomew";
}
}
#Moveable holidays in September
elsif ( $date->mon == 9 ) {
if ( $date->mday == 14 ) {
return "Holy Cross Day";
}
if ( $date->mday == 21 && $lectionary eq 'acna' ) {
return "St. Matthew";
}
if ( $date->mday == 29 && $lectionary eq 'acna' ) {
return "Holy Michael & All Angels";
}
}
#Moveable holidays in October
elsif ( $date->mon == 10 ) {
if ( $date->mday == 18 && $lectionary eq 'acna' ) {
return "St. Luke";
}
if ( $date->mday == 28 && $lectionary eq 'acna' ) {
return "St. Simon & St. Jude";
}
}
#Moveable holidays in November
elsif ( $date->mon == 11 ) {
if ( $date->mday == 30 && $lectionary eq 'acna' ) {
return "St. Andrew";
}
}
#Moveable holidays in December
elsif ( $date->mon == 12 ) {
if ( $date->mday == 21 && $lectionary eq 'acna' ) {
return "St. Thomas";
}
if ( $date->mday == 26 && $lectionary eq 'acna' ) {
return "St. Stephen";
}
if ( $date->mday == 27 && $lectionary eq 'acna' ) {
return "St. John";
}
if ( $date->mday == 28 && $lectionary eq 'acna' ) {
return "Holy Innocents";
}
}
else {
confess "Date [" . $date->ymd . "] is not a known or valid date.";
}
}
=head2 _buildFixedDays
Private method that takes the Time::Piece date given at construction and determines if the date is one of many fixed (non-moveable) feasts in the liturgical calendar. Fixed feasts are taken from the Anglican Church in North America's revision of the...
=cut
sub _buildFixedDays {
my $date = shift;
my $lectionary = shift;
#Fixed holidays in January
if ( $date->mon == 1 ) {
if ( $date->mday == 1 ) {
return {
commonName => "Holy Name",
season => 'Christmas'
};
}
if ( $date->mday == 6 ) {
return {
commonName => "The Epiphany",
season => 'Epiphany'
};
}
}
#Fixed holidays in February
elsif ( $date->mon == 2 ) {
}
#Fixed holidays in March
elsif ( $date->mon == 3 ) {
}
#Fixed holidays in April
elsif ( $date->mon == 4 ) {
}
#Fixed holidays in May
elsif ( $date->mon == 5 ) {
}
#Fixed holidays in June
elsif ( $date->mon == 6 ) {
}
#Fixed holidays in July
elsif ( $date->mon == 7 ) {
}
#Fixed holidays in August
elsif ( $date->mon == 8 ) {
if ( $date->mday == 6 && $lectionary eq 'acna' ) {
return {
commonName => "The Transfiguration",
season => 'Ordinary'
};
}
}
#Fixed holidays in September
elsif ( $date->mon == 9 ) {
}
( run in 1.610 second using v1.01-cache-2.11-cpan-d8267643d1d )