Jan 08 2007

My calendar class

After several hours of playing with php I think I’ve finally developed a stable calendar class.

You’d think that making a calendar is easily done, well it’s not.

The biggest challenge I’ve discovered was php’s date(‘W’) function.

Sometimes it’s 53, or even 54. So you can’t rely on that.

In the end I figured out the best way to generate the calendar is to increment the week yourself whenever the day chances. date(‘W’) wants Monday to be the first day of the week, and most calendars I’ve dealt with have Sunday as the first day of the week.

Oh well the code is out there, and available

It’s basic, and only allows 1 event per day -that’s all I needed- You could easily change
$this->events["$y"]["$m"]["$d"] = array('desc' => $desc, 'link' => $link);
to
$this->events["$y"]["$m"]["$d"][] = array('desc' => $desc, 'link' => $link);

Then add a foreach/implode for in generate_month() depending on your needs.

Not really exciting, but it’s there.

Erm

Leave a Reply

You must be logged in to post a comment. Login now.