#!/usr/bin/perl use Date::Calc qw(:all); our @dates = qw(2004-09-01 2004-09-05 2004-09-09 2004-09-19 2004-09-20 2004-09-21 2004-09-22 ); print "Content-type: text/html\n\n"; print_calendar("09", "2004"); sub print_calendar { # $month is the two-digit number for the month, January being 01 and December being 12, etc. # $year is the full four-digit representation for the year, ie. 2001 my($month, $year) = @_; my @table = ("S", "M", "T", "W", "T", "F", "S"); my $start_day = Day_of_Week($year, $month, 1); my $end_day = Days_in_Month($year, $month); my $bgcolor; $start_day = $start_day % 7; for($i = 0; $i < $start_day; $i++) { push(@table, ' '); } for($i = 1; $i <= $end_day; $i++) { push(@table, $i); } for($i = 0; $i < (35 - ($end_day + $start_day)); $i++) { push(@table, ' '); } print ""; my $count = 0; foreach $day (@table) { $found = 0; if($count % 7 == 0) { print "";} if($day < 10) { $date = "$year-$month-" . 0 . $day; } else { $date = "$year-$month-$day"; } # this function you would rewrite to set the $found variable whenever the current date matches a date that has content. You'd fill @dates or whatever variable with the valid dates and then compare them to $date, which is the current date foreach(@dates) { if($_ eq $date) { $found = 1; last; } } if($found) { print ""; } else { print ""; } if($count %7 == 6) { print "";} $count++; } print "
"; print "" . Month_to_Text($month) . " $year
$day$day
"; }