The lines I am currently thinking along is to analyse the difference between dates[0] and dates[1]. If the difference is 2 or more to insert calendars according to the difference. However I am still tripping up somewhere and I believe that it is the test on populating the calendar with days.

Perhaps a kindly monk would show me the error of my ways...

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 :) )

In reply to Re: Re: printing calendars using HTML::CalendarMonth by jonnyfolk
in thread printing calendars using HTML::CalendarMonth by jonnyfolk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.