#!/usr/bin/perl -w use strict; use CGI qw(:standard); use Date::Calc qw(:all); use HTML::AsSubs; use HTML::Element; use HTML::CalendarMonth; use Data::Dumper; my @Calendar = qw~732281 732282 732283 732284 732285 732286 732287 732288 732289 732290 732239 732240 732241 732242 732243 732244 732245 732246 732247 732401 732402 732403 732404 732405 732406 732407 732408 732409 732410 732411 732412 732413 732414 732415 732451 732452 732453 732454 732455 732456 732457 732458 732459 732460 732461 732462 732463 732464 ~; #@Calendar = qw~732661 732662 732663 732664 732665 732666 732667 732668 732669 732670 732671 732672 732673 732674 732675 732676~; my @dates = sort @Calendar; my ( $param_year, %cal, $day_first, $day_last, @color, %cal, @cals, $line ); print header(), start_html(-title => "Calendars"); my ($year1, $month1, $day1) = Add_Delta_Days(1, 1, 1, $dates[0] - 1); my ($year2, $month2, $day2) = Add_Delta_Days(1, 1, 1, $dates[$#dates] - 1); #uncomment lines below if you want to start calendar from current month (undef,undef,undef,undef,$month1)=localtime(); $month1++; if (!defined($param_year)) { $param_year=$year1;} foreach($year1..$year2) { $cal{$_}=[]; } #print Dumper(\%cal); my $year=$year1; while($year<$year2 || $month1<=$month2) { my $new_c = new HTML::CalendarMonth(year => $year, month => $month1); my $result = $new_c->last_row; unless ($result == 7) { $new_c->maxrow($new_c->maxrow + 1); } $day_first=Date_to_Days($year,$month1,1); $day_last=$day_first + Days_in_Month($year,$month1)-1; #search days of current month @color = map { get_day($_) } grep { $_>=$day_first && $_<=$day_last } @dates; $new_c->item($new_c->month, $new_c->year)->wrap_content( font({ size => '2' }) ); $new_c->item($new_c->dayheaders)->wrap_content( font({ size => '2' }) ); if(@color) { $new_c->item( @color )->wrap_content( strike( font({ size => 3}) )); $new_c->item( @color )->attr(bgcolor => 'red'); } push(@{$cal{$year}}, $new_c); if ($month1<12) {$month1++;} else {$month1=1;$year++;} } my(undef,undef,undef,undef,undef,$curyear)=localtime(); $curyear+=1900; foreach $year($year1..$year2) { @cals=@{$cal{$year}}; # Generate container table my $t = new HTML::ElementTable(maxrow => int($#cals/4), maxcol => ($#cals<4)?$#cals:3); #$t->attr('border',1); # Populate container table for my $calnum (0..$#cals) { my $col = $calnum %4; my $row = int($calnum / 4); $t->cell($row, $col)->push_content($cals[$calnum]); } $line=$t->as_HTML; print $line; } print end_html(); exit(0); sub get_day($) { my(undef,undef,$day)=Add_Delta_Days(1,1,1,$_[0]-1); $day; }