I want to generate html calendars
I actually have code that does this, which I use to generate study calendars for a quiz team I coach. Hmmm..., come to think of it, I also have code elsewhere that generates HTML calendars for other purposes. It's not hard.
with the ability to customize the appearance.
Customize the appearance using CSS.
Is HTML::CalendarMonth my best option
I don't know. I always just use DateTime myself. It's not like generating a calendar is hard...
sub html_calendar { my ($month, $year, $eventshashref) = @_; my $dt = DateTime->new(year => $year, month => $month, day => 1, ); my $calendar = qq[ <table class="calendarmonth"><thead> <tr><th colspan="7" class="monthname">] . $dt->month_name . qq[ $yea +r</th></tr> <tr><th>Sun</th><th>Mon</th><th>Tue</th><th>Wed</th><th>Thu</th><th> +Fri</th><th>Sat</th></tr> </thead><tbody> <tr>]; $calendar .= '<td class="othermonth"> </td>' for 1 .. ($dt->dow + % 7); while ($dt->month == $month) { $calendar .= qq[<td><span class="daynum">] . $dt->mday . '</span>' +; if (ref $eventshashref and exists $$eventshashref{$dt->mday}) { my $class = $$eventshashref{$dt->mday()}{class}; my $time = $$eventshashref{$dt->mday()}{time}; my $desc = $$eventshashref{$dt->mday()}{shortdesc}; my $tooltip = $$eventshashref{$dt->mday()}{longdesc}; $calendar .= qq[<div class="calendarevent $class"><span class="e +venttime">$time</span> <abbr title="$tooltip">$desc</abbr></div>]; } $calendar .= qq[</td>]; $dt = $dt->add(days => 1); if ($dt->dow == 7) { $calendar .= "</tr>\n <tr>", } } $calendar .= qq[</tr>\n</tbody></table>]; return $calendar; }
Call it thusly:
my $cal = html_calendar(11, 2006, { 23 => {class => 'holiday', time => '', shortdesc => 'Thanksgiving', longdesc => 'Stay home and stuff yourself.'}});HTH.HAND.
In reply to Re: Looking for easy way to generate html calendars
by jonadab
in thread Looking for easy way to generate html calendars
by twotone
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |