#!/usr/local/bin/perl -w # HTML Calendar by -Sneex- :] Of course... # Copyright (C) 2000 by WCJones; All Rights Reserved... # Version 0.02A -- Turns month of execution into an HTML Table... ########################################################################### # UPDATE: You may wish to see the WebTechniques solution created by # Randal L. Schwartz ( merlyn@stonehenge.com ) at - # http://www.stonehenge.com/merlyn/WebTechniques/col66.listing.txt ########################################################################### use strict; use diagnostics; my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime; # 0-8 = 9 elements... # Returns: seconds, minutes, hour, Day of Month, Month (0-11; Jan=0), # Year (in 00 format; add 1900 to get actual 4 digits), # Day of Week (0-6; Su=0), Day of Year, and Is Daylight Savings Time in effect? # Project start Year (2000) was a leap year... my @days = qw/ Sunday Monday Tuesday Wednesday Thursday Friday Saturday /; my @months = qw/ January February March April May June July August September October November December /; my @mlimits = qw/ 31 29 31 30 31 30 31 31 30 31 30 31 /; # Force a few tests; $mon = 6; $mday = 1; $wday = 6; my $cal = "$days[$wday] $months[$mon] $mday, " . ($year + 1900) . " \@ "; $cal .= sprintf("%02d:%02d:%02d", $hour, $min, $sec); $cal .= ($hour < 12) ? " AM": " PM"; my $first = $wday if ($mday == 1); # The First of this Month is on Week Day... my $indx0 = $mday; my $indx1 = $wday; unless ($mday == 1) { while ($indx0-- != 1) { $indx1 = 6 if (--$indx1 < 0); # If we were on Sun, reset it as Sat... } $first = $indx1; # Then the First of this Month is on this Week Day... } my $filename = $months[$mon] . ($year + 1900); open (oFile, ">$filename.html") or die $!; print oFile "\
| $cal | ||||||
| Su | Mo | Tu | We | Th | Fr | Sa |
| $Sunday | $Monday | $Tuesday | $Wednesday | $Thursday | $Friday | $Saturday |