NAME

PerpetualCalendar

EXAMPLE

#!/usr/local/bin/perl

use diagnostics;
use strict;
use warnings;
use DateTime::PerpetualCalendar;
use Getopt::Long;

my ($year, $month, $mday);
GetOptions("year=i" => \$year, "month=i" => \$month,
    "mday=i" => \$mday);

sub usage
{
    print "USAGE: $0 --year=YYYY --month=MM --mday=DD\n";
    print "example: $0 --year=1972 --month=2 --mday=7";
    print "    (should be Monday)\n";
    exit 0;
}

&usage if (!defined($year) or !defined($month) or
           !defined($mday));

my $result = dow($year, $month, $mday);

print "Sunday\n" if ($result == 0);
print "Monday\n" if ($result == 1);
print "Tuesday\n" if ($result == 2);
print "Wednesday\n" if ($result == 3);
print "Thursday\n" if ($result == 4);
print "Friday\n" if ($result == 5);
print "Saturday\n" if ($result == 6);

DESCRIPTION

This is another implementation of a perpetual calendar. However, dates prior to October 15, 1582 (the Gregorian Reformation) were not taken into consideration, thus, the day of week for them would be incorrectly reported.

A return value of 0 means that the day of week is "Sunday". A return value of 1 is "Monday", 2 is "Tuesday", 3 is "Wednesday", 4 is "Thursday", 5 is "Friday", and 6 is "Saturday".

REFERENCE

"A Mental Calendar" by Michael Keith, Journal of Recreational Mathematics, 1975-1976.

LICENSE

This program is free software; you can redistribute it or modify it under the terms of the GNU General Public License.

AUTHOR

Julius C. Duque <jcduque (AT) lycos (DOT) com>