#!/usr/bin/perl # # CALENDAR.CGI # print "Content-type: text/html\n\n"; print<<"EOF"; SD#91: Calendar Page
School District #91
Search
spacer
Area Map at the Heart of BC
Innovation in Education
EOM ($month,$day,$year,$weekday) = &jdate($firstday); # for ($a = 0; $a < $weekday; $a++) { print "\t\t\n"; # } for ($thisday = $firstday; $thisday <= $lastday; $thisday++) { ($month,$day,$year,$weekday) = &jdate($thisday); if ($weekday == 0) { print "\t\n\t\n"; } print "\t\t\n"; } print "\t\t" if ($weekday != 6); for ($a = 1; $a <= 12; $a++) { $monthoptions .= "
District Overview -- School Calendar
EOF require 'date.pl'; require 'setup.pl'; require 'parse_form.pl'; &parse_form; $today = &today(); ($thismonth,$day,$thisyear,$weekday) = &jdate($today); $nowyear = $thisyear; if ($form{'month'} ne "") { $thismonth = $form{'month'}; } if ($form{'year'} ne "") { $thisyear = $form{'year'}; } # # Figure out how many days in this month. # $firstday = &jday($thismonth,"1",$thisyear); $temp = $firstday + 32; ($month,$day,$year,$weekday) = &jdate($temp); $lastday = $temp - $day; $thismonthname = &monthname($thismonth); # # Gather our data # open (IN, "$datafile") || die "Can't open $datafile - $!"; while () { s/\n//; $data .= $_; } close (IN); @items = split (/
/, $data); shift (@items); foreach (@items) { @bits = split (/
/); $id = shift (@bits); $events[$id] = join ("
", @bits); $date = shift (@bits); $date_by_id{$date} .= "\t%$id%"; $startdate_by_id{$date} .= "\t%$id%"; if ($date > $maxdate) { $maxdate = $date; } # # Parse the duration and add it to subsequent days # $days = shift (@bits); for ($b = 1; $b < $days; $b++) { $ref = $date + $b; $date_by_id{$ref} .= "\t%$id%"; } } if (($form{'format'} ne "table") || ($form{'format'} ne "long")) { $form{'format'} = $defaultformat; } if ($form{'format'} eq "table") { # # TABLE Style Calendar # print <
$headerfont$thismonthname, $thisyear
$headerfont Sunday $headerfont Monday $headerfont Tuesday $headerfont Wednesday $headerfont Thursday $headerfont Friday $headerfont Saturday
 
"; print $dayfont; print "$day"; print "
"; if ($date_by_id{$thisday} =~ /\t/) { $temp = $date_by_id{$thisday}; $temp =~ s/%//g; @idlist = split (/\t/, $temp); shift (@idlist); undef (%calendarevents); foreach $id (@idlist) { @data = split (/
/, $events[$id]); $ref = $data[2] . (1000000000 + $id); $calendarevents{$ref} = "$data[3]

"; } foreach (sort keys %calendarevents) { print $calendarevents{$_}; } } print "
 
$headerfont Select a Month to View:
EOM } else { # # LONG Style Calendar # print ""; $thisday = $today - 14; $outputcount = 1; while ($finished ne "yes") { $thisday++; if (($outputcount > $longmax) || ($thisday > $maxdate)) { $finished = "yes"; } next unless ($startdate_by_id{$thisday} =~ /\t/); ($month,$day,$year,$weekday) = &jdate($thisday); if ($month ne $lastmonth) { print "\n"; $lastmonth = $month; } $temp = $startdate_by_id{$thisday}; $temp =~ s/%//g; @idlist = split (/\t/, $temp); shift (@idlist); undef (%calendarevents); foreach $id (@idlist) { @data = split (/
/, $events[$id]); $ref = $data[2] . (1000000000 + $id); $datestring = &weekday($weekday) . ", $day" . &date_suffix($day); if ($data[1] > 1) { ($endmonth,$endday,$endyear,$endweekday) = &jdate($thisday + $data[1]); $datestring .= "
to
" . &weekday($endweekday) . ", "; if ($endmonth ne $month) { $datestring .= &monthname($endmonth) . " "; } $datestring .= $endday . &date_suffix($endday); } if ($data[4] ne "") { $location = "
Location: $data[4]"; } else { $location = ""; } $eventtime = $data[2]; ($hrs, $mins) = split (/:/, $data[2]); if ($hrs ne "") { $am_pm = "AM"; if ($hrs >= 12) { $am_pm = "PM"; $hrs -= 12; } if ($hrs < 1) { $hrs = 12; } $timestring = "
Time: $hrs:$mins $am_pm"; } $calendarevents{$ref} = <
EOM } foreach (sort keys %calendarevents) { print $calendarevents{$_}; } $outputcount++; } print "
 
$headerfont" . &monthname($month) . ", $year
$headerfont
$datestring
$location $timestring
$headerfont
$data[3]

$data[5]
 

"; } print<<"EOF";

© 2002 - SD #91 - Nechako Lakes  |  Telephone: 1-250-567-2284  |   Fax: 1-250-567-4639  |  Email: webmaster\@mail.sd91.bc.ca

EOF