Jump to content

I need to figure out why my calendar class sucks. (dates are off)


Kinsbane

Recommended Posts

So, I didn't program this class and I've always had trouble figuring it out. We moved our site to a new server and now some months have incorrect dates on incorrect days (usually only off by one day/date).

 

So, here's how it works. A query on the events table is run that grabs all events. It then runs a while loop and adds the dates it finds for the current month and year into the $cal object, like so:

while($data = mysql_fetch_array($result, MYSQL_ASSOC)) {

if($data['event_date'] > $month_start and $data['event_date'] < $month_end) {

        $cal->add_event($data['event_title'], $data['event_date'], $data['event_length'], "events/event/{$data['event_id']}", $data['event_status'], $data['event_id']);
}
}

 

Then, the calendar is displayed:

$body .= $cal->display(mktime(0,0,0,$month,1,$year));

 

The $cal->display() method generates an HTML string which is added to $body for output.

 

I've tried all I can think of to fix this problem. You can see it further in the attachments I provided, which show October 2009, Nov 2009, and December 2009 - in this set of three, only November has the correct dates on the correct days. If you look at October, you'll see it shows the 31st being on a Friday, when it should be on a Saturday.

 

I've also attached the class for people to look at.

 

[attachment deleted by admin]

may be a stupid question... but did you take into account leap years?

 

You know, now that I think of it, no, I didn't, but maybe the other guy who programmed the class didn't think of that either?

 

I was messing around with it more on Friday afternoon, and there's something wrong in general with November of this year - no events are showing up on the calendar after the first one,

which starts on the 1st of November and the 1st of November is on the first day on the first week of the month.

 

Halloween is on a Saturday, so the first would be the following Sunday.

 

This year, however, isn't a leap year so I don't see how that would affect anything...

And I really wish I could completely re-do the calendar functionality altogether. I am in love with these two calendar implementations:

 

http://www.stefanoverna.com/log/create-astonishing-ical-like-calendars-with-jquery

 

http://davidwalsh.name/dw-content/php-calendar.php

 

... but the folks here are stuck on being able to see events that span multiple days. I can appreciate it but I don't think it's drastically easier to read the event from a list rather than a colored bar and finding its subsequent match in a list of the events...

 

Ugh, I dunno what to do. I just want this fixed and I Don't know how. :(

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.