while ( defined $dates[0] ) {
my $new_c;
my $days = $dates[0];
my $days1 = $dates[1];
my ( $year, $month, $day ) = Add_Delta_Days( 1, 1, 1, $days - 1 );
my ( $year1, $month1, $day1 );
unless (! $days1) {
( $year1, $month1, $day1 ) = Add_Delta_Days( 1, 1, 1, $days1 -
+ 1 );
}
my $diffmonth = $month1 - $month;
if ($diffmonth >= 2) {
my $count = 0;
while ($count < $diffmonth) {
$count += 1;
$month++;
$new_c = new HTML::CalendarMonth ( year => $year1, month =
+> $month );
push (@cals, $new_c);
}
} else {
$new_c = new HTML::CalendarMonth ( year => $year, month => $mo
+nth );
push (@cals, $new_c);
@dates = CreateCal( $year, $month, @dates );
push( @cals, $new_c );
}
}
# Embolden headers
foreach my $calnum ( 0 .. $#cals ) {
my $cal = $cals[$calnum];
if (@{ $days[$calnum] }) {
my @color = @{ $days[$calnum] }; # the days to be colored
}
$cal->item( $cal->month, $cal->year )->wrap_content( font({ size =>
+ '2' }) );
$cal->item( $cal->dayheaders )->wrap_content( font({ size => '2' })
+ );
$cal->item( @color )->wrap_content( font({ size => 3, color => 'red
+' }) );
}
# Generate container table
my $t = new HTML::ElementTable ( maxrow => 36, maxcol => 4 );
my $row = 0;
# 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] );
}
print $t->as_HTML;
print end_html();
exit(0);
sub CreateCal {
my ( $cyear, $cmonth, @dates ) = @_;
my ( @day, @temp );
foreach my $days ( @dates ) {
my ( $year, $month, $day ) = Add_Delta_Days( 1, 1, 1, $days - 1 );
if ( $year == $cyear && $month == $cmonth ) {
push ( @day, $day );
} else {
push ( @temp, $days );
}
}
push ( @days, [ @day ] ); # store the days of each calendar
return @temp;
}
Thanks due as always to Mr. Muskrat and mojotoad for their help with this code (the mistakes are my own :) ) |