Rendering Calendars in HTML
By Randal L. Schwartz
I keep a text-file link from my home page that shows all of the places that my crazy conference and training schedule takes me. Each entry is a single line showing a date range in day-month-year format, followed by a short phrase, and possibly a URL for further information.
For a long time, I've been meaning to move these public schedule items out of a flat file and into a real database. Then I could have them display as a nice HTML table calendar, with a link from my page. The convenience of just editing the flat file kept me from getting around to it until it occurred to me that I could keep my flat-file data source, and merely interpret the data as it was.
I whipped out the documentation for Date::Manip (from the CPAN) and figured out the correct date format with which I could compute date ranges. I then wrote a regular expression or two to pick up the date range pieces and feed them to the Date::Manip routines for computation. Within a short time, I had a program that output the text of each activity, preceded by every date connected to that item. Cool.
Next I had to render it in a nice HTML table. Bleh. I hated the thought of even more date calculations and HTML wrangling, even though Date::Manip can do just about everything. Luckily, I recalled stuffing away a note to look at HTML::CalendarMonthSimple, and sure enough, this module was exactly the ticket.
But after hooking together the date-extraction logic with the HTML rendering logic, I discovered that my poor little ISP's shared Web server was getting nailed each time I tweaked the HTML color settings and hit reload.