Date-DayOfWeek

 view release on metacpan or  search on metacpan

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


Date::DayOfWeek - Determine the day of the week for any date.

=head1 SYNOPSIS

  use Date::DayOfWeek;
  $dow = dayofweek( 25, 10, 1971 ); # dd, mm, yyyy

=head1 DESCRIPTION

Calculates the day of the week for any date in the Gregorian calendar
(1563 and following).
Based on the Doomsday algorithm of John Conway.

=cut

#}}}

# sub dayofweek {{{

=head1 dayofweek

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

    Revision 1.17  2001/06/11 01:49:05  rbowen
    Additional docs. Added Sneeze.pm

    Revision 1.16  2001/06/10 18:46:03  rbowen
    Moved isleap functionality into Date::Leapyear. Added Birthday.pm and
    Nails.pm as examples of the strange things that people believe - or
    believed a few hundred years ago, with regard to days of the week.

    Revision 1.15  2001/06/06 02:29:14  rbowen
    Added some more doomsday tests. Removed dayofweek tests that referred
    to years before the Gregorian calendar. Extended the range of
    Doomsday.pm indefinately into the future. And a small bug fix in
    DayOfWeek.pm

    Revision 1.14  2001/06/06 01:41:45  rbowen
    Made the calculation a little more elegant, if somewhat less
    informative. Thanks for patch from Jerrad Pierce. Thanks for
    various suggestions from David Pitts.

    Revision 1.13  2001/05/27 19:34:46  rbowen
    Rearranged argument order. day month year makes more sense.

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

=cut

# sub doomsday {{{

sub doomsday {
    my $year = shift;

    $year = ( localtime(time) )[5] unless $year;

    if ($year < 1583) {
        warn "The Gregorian calendar did not come into use until 
1583. Your date predates the usefulness of this algorithm."
    }

    my $century = $year - ( $year % 100 );

    my $base = ( 3, 2, 0, 5 )[ ( ($century - 1500)/100 )%4 ];

    my $twelves = int ( ( $year - $century )/12);
    my $rem = ( $year - $century ) % 12;
    my $fours = int ($rem/4);

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

=head1 AUTHOR

Rich Bowen (rbowen@rcbowen.com)

=head1 Doomsday

Doomsday is a simple way to find out what day of the week any event occurs, in
any year. It was invented by Dr John Horton Conway.

In conjunction with Date::DayOfWeek, it can calculate the day of the
week for any date since the beginning of the Gregorian calendar.

The concept of doomsday is simple: If you know this special day
(called "doomsday") for a given year, you can figure out the day of
the week for any other day that year by a few simple calculations that
you can do in your head, thus:

The last day of February is doomsday. That's the 28th most years, and
the 29th in leap years.

The Nth day of the Nth month is doomsday, for even values of N. That



( run in 0.574 second using v1.01-cache-2.11-cpan-5dc5da66d9d )