Date-Advent
view release on metacpan or search on metacpan
lib/Date/Advent.pm view on Meta::CPAN
package Date::Advent;
use v5.22;
use strict;
use warnings;
use Moose;
use MooseX::StrictConstructor;
use Carp;
use Time::Piece;
use Date::Lectionary::Time qw(nextSunday prevSunday);
use namespace::autoclean;
=head1 NAME
Date::Advent - Calculate the Sundays of Advent
=head1 VERSION
Version 1.20180423
=cut
use version; our $VERSION = version->declare("v1.20180423");
=head1 SYNOPSIS
Date::Advent takes a Time::Piece date and calculates all four Sundays of Advent for the current Christian liturgical year.
As Advent is the beginning of the Christian liturgical calendar, this usually results in the date for Advent in the current year being dates in the past. E.g. The Sundays of Advent returned for 12. March 2016 would be 29. November 2015, 6. December ...
use Time::Piece;
use Date::Advent;
my $testAdvent = Date::Advent->new(date => Time::Piece->strptime("2016-01-01", "%Y-%m-%d"));
say $testAdvent->firstSunday; #Gives date for first Sunday of Advent
say $testAdvent->secondSunday; #Gives date for second Sunday of Advent
say $testAdvent->thirdSunday; #Gives date for third Sunday of Advent
say $testAdvent->fourthSunday; #Gives date for fourth Sunday of Advent
say $testAdvent->christmas; #Gives date of Christmas
=head1 Object Attributes
=head2 date
Time::Piece date object. Only attribute required at object construction.
=head2 christmas
Time::Piece attribute for Christmas Day as calculated from the C<date> given at object construction.
=head2 firstSunday
Time::Piece attribute for the first Sunday of Advent as calculated from the C<date> given at object construction.
=head2 secondSunday
Time::Piece attribute for the second Sunday of Advent as calculated from the C<date> given at object construction.
=head2 thirdSunday
Time::Piece attribute for the third Sunday of Advent as calculated from the C<date> given at object construction.
=head2 fourthSunday
Time::Piece attribute for the fourth Sunday of Advent as calculated from the C<date> given at object construction.
=cut
has 'date' => (
is => 'ro',
isa => 'Time::Piece',
);
has 'christmas' => (
is => 'ro',
isa => 'Time::Piece',
init_arg => undef,
writer => '_setChristmas',
);
has 'firstSunday' => (
is => 'ro',
isa => 'Time::Piece',
init_arg => undef,
writer => '_setFirstSunday',
);
has 'secondSunday' => (
is => 'ro',
( run in 3.620 seconds using v1.01-cache-2.11-cpan-75ffa21a3d4 )