#!/usr/bin/perl -w # Blosxom Plugin: calendar # Author: Todd Larason (jtl@molehill.org) with features by Ben Guaraldi (benj@bluesock.org) # Version: 0+1i # Blosxom Home/Docs/Licensing: http://www.raelity.org/blosxom # Categories plugin Home/Docs/Licensing: # http://molelog.molehill.org/blox/Computers/Internet/Web/Blosxom/Calendar/ package calendar; # --- Configuration Variables --- # output format # 'table' -> simple table; simplest, suitable for most people my $output_format = 'table'; # names in your preferred language my @monthname = qw/January February March April May June July August September October November December/; my @weekdayname = qw/Sun Mon Tue Wed Thu Fri Sat/; # Do you want < and >'s that point to the next and previous # month? If so, leave $nav = 1. Else, put $nav = 0. $nav = 1; # Put the date that you want your calendar to start at. # (e.g,, Mine starts at 9/1/04, so when you're in September, # you can't go backwards any more months.) $calstartdate = "20040901"; (undef, undef, undef, $dd, $mm, $yyyy) = localtime(time); $calenddate = sprintf("%04d%02d%02d", $yyyy+1900, $mm+1, $dd); # The end date is set to the present date. If you want to have the # calendar go into the future, then uncomment this line and enter the # desired date: # $calenddate = "20100901"; # --- End of Configuration Section --- use Time::Local; $calendar = ''; my %days; sub report_month_start { my ($year, $month, $monthname) = @_; my $results = ''; local $_; my $prevday, $nextday, $prevmonth, $nextmonth, $prevyear, $nextyear, $tempmonth; $prevyear = $nextyear = $year; $prevmonth = $month - 1; $nextmonth = $month + 1; if ($month == 1) { $prevmonth = 12; $prevyear = $year - 1; } elsif ($month == 12) { $nextmonth = 1; $nextyear = $year + 1; } $prevday = days_in_month($prevyear, $prevmonth); $nextday = "01"; $prevmonth = prependzero($prevmonth); $nextmonth = prependzero($nextmonth); $tempmonth = prependzero($month); if ($output_format eq 'table') { $results = qq!
| \n! . # qq!\<\n! . qq!\<\n! . qq! | \n!; } else { $results .= qq!\n! . qq! | \n!; } } $results .= qq!! . qq!$monthname $year | \n!; if ($nav) { if ("$nextyear$nextmonth" . "01" <= $calenddate) { $results .= qq!\n! . # qq! \>\n! . qq! \>\n! . qq! | \n!; } else { $results .= qq!\n! . qq! | \n!; } } $results .= qq!||||||
|---|---|---|---|---|---|---|---|---|---|---|
| $_ | \n! foreach (@weekdayname); $results .= qq!||||||||||
| \n! if ($output_format eq 'table'); return qq!!; } sub report_day_link { my ($year, $month, $day) = @_; my $zday, $zmonth; $zmonth = prependzero($month); $zday = prependzero($day); return qq! | $day | \n! if ($output_format eq 'table'); return qq!!; } sub report_day_nolink { my ($year, $month, $day) = @_; return qq!$day | \n! if ($output_format eq 'table'); return qq!!; } sub report_week_end { return qq!||||||||