use strict;
use SimpleCal;
use POSIX qw (setlocale);
use Locale::Messages qw (LC_MESSAGES);
use Locale::TextDomain ('com.cantanea.simplecal');
use vars qw ($VERSION);
$VERSION = '1.0';
setlocale (LC_MESSAGES, "");
my $package_name = "SimpleCal";
my @now = localtime;
my $year = $now[5] + 1900;
my $month = $now[4];
my $month_name = SimpleCal::month_name ($month);
print "\t$month_name $year\n";
foreach my $i (0 .. 6) {
printf "%6s", abbr_week_day ($i);
}
print "\n";
my $first_day = $now[3] - $now[6];
if ($first_day > 0) {
$first_day %= 7;
$first_day -= 7;
}
my $last_day;
if ($month == 1) {
if (SimpleCal::is_leap_year ($year)) {
$last_day = 29;
} else {
$last_day = 28;
}
} elsif ($month == 3 || $month == 5 || $month == 8 || $month == 10) {
$last_day = 30;
} else {
$last_day = 31;
}
my $day_of_week = 0;
foreach my $mday ($first_day .. $last_day) {
if ($mday <= 0) {
printf "%6s", ' ';
} else {
printf "% 6d", $mday;
}
++$day_of_week;
if ($day_of_week == 7) {
$day_of_week = 0;
print "\n";
}
}
print "\n" if $day_of_week;
__END__
Local Variables:
mode: perl
perl-indent-level: 4
perl-continued-statement-offset: 4
perl-continued-brace-offset: 0
perl-brace-offset: -4
perl-brace-imaginary-offset: 0
perl-label-offset: -4
cperl-indent-level: 4
cperl-continued-statement-offset: 2
tab-width: 4
End: