#!/usr/bin/perl # I wanted something VERY SIMPLE for generating an # HTML calendar. I didn't want to wade through the interface # for HTML::Calendar::Simple, or worry about Entities. # This script looks at the time, backtracks to the first of # the month, and then prints out an HTML calendar for this # month. You can manipulate the month being printed by fiddling # with the $now variable and you can put information into the # calendar easily where commented. # Oakbox Productions - Richard Still (oakbox) use strict; my $message; # variable to hold output my $now = time; my @wday = localtime($now); my %dayrev = ( "0" => "Sun", "1" => "Mon", "2" => "Tue", "3" => "Wed", "4" => "Thu", "5" => "Fri", "6" => "Sat"); my %monrev = ( "0" => "Jan", "1" => "Feb", "2" => "Mar", "3" => "Apr", "4" => "May", "5" => "Jun", "6" => "Jul", "7" => "Aug", "8" => "Sep", "9" => "Oct", "10" => "Nov", "11" => "Dec"); use Time::Local; $message.=qq( $monrev{$wday[4]}
); # I have to move the start date a little bit to get Sunday # over to the first position my $fday = timelocal(0,0,0,1,$wday[4],$wday[5]); my @ltime = localtime($fday); if($ltime[6] ne "0"){ $message.=qq(); foreach my $cl (0...($ltime[6] - 1)){ $message.=qq( ); } }else{ $message.=qq(); } my $endm; foreach my $daycount (1...31){ my $thisday; eval { $thisday = timelocal(0,0,0,$daycount,$wday[4],$wday[5]); }; if( $@ ){ next; } my @ltime = localtime($thisday); $endm = $ltime[6]; # signal to next section about what day we ended on my $color = qq(); ## This is where you want to put stuff INTO your calendar ## but that's optional :) $message.=qq(\n); if($ltime[6] eq "6"){ $message.=qq(\n); } } # close up the table by filling in any missing days if($endm ne "6"){ foreach my $cl (($endm+1)...6){ $message.=qq( ); } } $message.=qq(
$dayrev{0} $dayrev{1} $dayrev{2} $dayrev{3} $dayrev{4} $dayrev{5} $dayrev{6}
 
$daycount

 

 
); # little html out template my $html_frame=qq(

$message

); print "Content-type: text/html\n\n"; print "$html_frame"; exit;