#!/usr/bin/perl -w use CGI qw(:all); use Date::Calc qw(Days_in_Month Day_of_Week Month_to_Text); print "Content-type:text/html\n\n"; my $Path="/home/public/davis/calender_2month.htm"; my %EMB = (); my $i; &getmonthvalue; exit(0); sub getmonthvalue { my $year=param("year"); my $month=param("month"); if(!$year) { $year = 2010; } if(!$month) { $month=1; } &monthvalue($month,$year,0); if($month >= 12) { $month = 1; $year = $year + 1; }else{ $month = $month + 1; } &monthvalue($month,$year,42); &buildnextprevious($month,$year,); print &printFile($Path, \%EMB); } sub monthvalue { my $month = shift; my $year = shift; $i = shift; my $monthtotext = Month_to_Text($month); my $noofdays = Days_in_Month($year,$month); my $dayofweek = Day_of_Week($year,$month,1); $EMB{"mnth$i"} = $monthtotext; $EMB{yr}=$year; $EMB{nextyr}=$year; $noofdays = $noofdays + $i; for(my $j=$i,$k=1;$j < $noofdays;$j++,$k++){ $EMB{$j + $dayofweek} = $k; } } sub buildnextprevious { my $newmonth = shift; my $newyear=shift; # NEXT SECTION if($newmonth == 1) { $EMB{yr} = $newyear - 1; } $EMB{Next} = qq( Next); # PREVIOUS SECTION if($newmonth == 2) { $newyear = $newyear-1; $newmonth = 14; }if($newmonth == 1) { $newyear = $newyear - 1; $newmonth = 11; }else{ $newmonth = $newmonth - 2; } $EMB{Previous} = qq( Previous); } sub printFile { my $readFile = shift; my $storeHashRef = shift; my $retFile=""; open (TEMPLATE, $readFile) or die "Open failed for template file ** $readFile **"; my $Line = ""; while (