Date-Easter

 view release on metacpan or  search on metacpan

README  view on Meta::CPAN


    easter() is simply an alias to gregorian_easter(), since that's what
    almost every country in the world currently uses.

    Date::Easter provides the following functions:

  julian_easter
        ( $month, $day ) = julian_easter( $year );

    Returns the month and day of easter in the given year, in the Julian
    calendar.

  gregorian_easter
        ( $month, $day ) = gregorian_easter( $year );

    Returns the month and day of easter in the given year, in the Gregorian
    calendar, which is what most of the world uses.

  easter
        ( $month, $day ) = easter( $year );

    Returns the month and day of easter in the given year, in the Gregorian
    calendar, which is what most of the world uses.

  orthodox_easter
        ( $month, $day ) = orthodox_easter( $year );

    Returns the month and day of easter in the given year, in the Orthodox
    calendar.

    From code by Pascalis Ligdas, based on original code by Apostolos
    Syropoulos

AUTHOR
    Rich Bowen <rbowen@rcbowen.com>

To Do
    The use of localtime and timelocal locks us into the epoch, which is a
    rather silly limitation. Need to move to Date::DayOfWeek or other module

lib/Date/Easter.pm  view on Meta::CPAN


=pod

Date::Easter provides the following functions:

=head2 julian_easter

    ( $month, $day ) = julian_easter( $year );

Returns the month and day of easter in the given year, in the Julian
calendar.

=cut

sub julian_easter {
    my ($year) = @_;
    my ( $G, $I, $J, $L, $month, $day, );
    $G     = $year % 19;
    $I     = ( 19 * $G + 15 ) % 30;
    $J     = ( $year + int( $year / 4 ) + $I ) % 7;
    $L     = $I - $J;
    $month = 3 + int( ( $L + 40 ) / 44 );
    $day   = $L + 28 - ( 31 * ( int( $month / 4 ) ) );
    return ( $month, $day );
}

=head2 gregorian_easter

    ( $month, $day ) = gregorian_easter( $year );

Returns the month and day of easter in the given year, in the
Gregorian calendar, which is what most of the world uses.

=cut

sub gregorian_easter {
    my ($year) = @_;
    my ( $G, $C, $H, $I, $J, $L, $month, $day, );
    $G = $year % 19;
    $C = int( $year / 100 );
    $H = ( $C - int( $C / 4 ) - int( ( 8 * $C + 13 ) / 25 ) + 19 * $G + 15 ) % 30;
    $I = $H - int( $H / 28 ) *

lib/Date/Easter.pm  view on Meta::CPAN

    $month = 3 + int( ( $L + 40 ) / 44 );
    $day   = $L + 28 - ( 31 * int( $month / 4 ) );
    return ( $month, $day );
}

=head2 easter

    ( $month, $day ) = easter( $year );

Returns the month and day of easter in the given year, in the
Gregorian calendar, which is what most of the world uses.

=cut

sub easter { return gregorian_easter(@_); }

# sub orthodox_easter {{{

=head2 orthodox_easter

    ( $month, $day ) = orthodox_easter( $year );

Returns the month and day of easter in the given year, in the
Orthodox calendar.

From code by Pascalis Ligdas, based on original code by
Apostolos Syropoulos

=cut


sub orthodox_easter {
    my $year   = shift;

    die "Invalid year for Gregorian calendar" if ($year < 1583);

    # Find the date of the Paschal Full Moon (based on Alexandrian computus)
    my $epact = ( ( $year % 19 ) * 11 ) % 30;
    my $fullmoon = 5 - $epact;
    $fullmoon += 30 if $fullmoon < -10;

    # Convert from Julian to Gregorian calender
    $fullmoon += int($year / 100) - int($year / 400) - 2;

    my $month = 4;

lib/Date/Easter.pm  view on Meta::CPAN


1;

=head1 AUTHOR

Rich Bowen <rbowen@rcbowen.com>

=head1 To Do

Since the dates that various countries switched to the Gregorian
calendar vary greatly, it's hard to figure out when to use
which method. Perhaps some sort of locale checking would be
cool?

I need to test the Julian easter calculations, but I'm a little
confused as to the difference between the Orthodox Easter and the
Julian Easter. I need to read some more.

The use of localtime and timelocal locks us into the epoch, which is a
rather silly limitation. Need to move to Date::DayOfWeek or other
module to calculate the day of the week. This should immediately make



( run in 0.507 second using v1.01-cache-2.11-cpan-c333fce770f )