Forums

[Plugin: ICS Calendar] Daylight savings time not working, even when client and server are in same zo (13 posts)

  1. Trevor Jacques
    Member
    Posted 4 weeks ago #

    Daylight savings time not working, even when client and server are in same zone

    For events after the start of daylight savings time next weekend, all times are off by one hour. For example, I created a test event in my Google calendar at 10:00, yet the plug-in shows the event at 11:00. This is a mission-critical show-stopper for us, and spoils an otherwise excellent plug-in. Is there any way this bug can be fixed quickly?

    http://wordpress.org/extend/plugins/wordpress-ics-importer/

  2. Trevor Jacques
    Member
    Posted 4 weeks ago #

    This is not fixed in 1.6.8 (WP 2.8.4).

    From what I can tell (my php skills are almost non-existent, but I've been tinkering with the icaldate_to_timestamp code to locate the problem), there seem to be problems defining $WPTimezone, $TZOffset, $TZOffsetDaylight, $utcOff, and $shift. The conditionals in the icaldate_to_timestamp are not working as they should.

    For example, dates in November show times one hour late, apparently because these times pass through the if($Z = 'Z') test. This is weird, because they then appear to not have the daylight time applied (mind you testing the conditionals in that branch show that the daylight branch is not called, either).

    This really is a mission-critical bug in an otherwise great plug-in. :-(

  3. randyhoyt
    Member
    Posted 2 weeks ago #

    Is this happening with recurring events? Or with non-recurring events? I see something similar with recurring events, while the non-recurring events are displayed correctly.

  4. pjaxon
    Member
    Posted 2 weeks ago #

    I just realized the same thing. A temporary hack that solved my [show-ics-events] issue is to fix one line of code in the "display_events" function found in the ics-functions.php file.

    $output .= (ICalEvents::format_date_range(($event['StartTime']-3600), ($event['EndTime']-3600), $event['Untimed'], $date_format, $time_format));

    Notice the "-3600" after both times. This takes the displayed time back an hour. Yes, its a hack... but nothing wrong with some duct tape until I can make amore permanent fix. I'll post a better solution when/if I figure it out. ~ pjaxon

  5. pjaxon
    Member
    Posted 2 weeks ago #

    p.s. To fix the [show-ics-calendar] feature, edit the cal-functions.php file and update the function "showCalendar". In the showCalendar function, change the line that handles the time to read as follows:

    $formated_date = (ICalEvents::format_date_range(($event['StartTime']-3600), ($event['EndTime']-3600), $event['Untimed'], $options['date_format'], $options['time_format']));

    I would quote the line numbers, but I've heavily modified my plugin and so the above is the best I can offer for the time being ~

  6. danatstadiumvolleyball
    Member
    Posted 2 weeks ago #

    Rather not have to hack... Any other info on a fix, is there a way to force one's server time to reflect the site time?

  7. pjaxon
    Member
    Posted 2 weeks ago #

    I agree... I hate to hack like that, but it buys me time until I get a better solution. The server time can be viewed from the plugin's admin tool & my server time is correct... I believe it's the plugin that's having issues. Obviously, with my hack, it will have to be reversed in the spring.

  8. danatstadiumvolleyball
    Member
    Posted 2 weeks ago #

    Could you order the steps for the above changes :)

  9. pjaxon
    Member
    Posted 2 weeks ago #

    The steps I took to modify the code so that it refelcts and hour difference are:

    1. Download the plugin's files from your server which can be found in the "/wp-content/plugins/wordpress-ics-importer" directory.
    2. Create a second set of these files for backup. They will be needed in the Spring when daylight savings changes back.
    3. Next, we need to edit the file called "ics-functions.php".
    4. Within "ics-functions.php" we now need to edit "function display_events".
    5. About 48 lines into the display_events function, we need to change
      $output .= (ICalEvents::format_date_range($event['StartTime'], $event['EndTime'], $event['Untimed'], $date_format, $time_format));

      to

      $output .= (ICalEvents::format_date_range(($event['StartTime']-3600), ($event['EndTime']-3600), $event['Untimed'], $date_format, $time_format));

    6. Save and close the php file
    7. Next, we need to edit the file cal-functions.php
    8. Within cal-functions.php, we need to edit the showCalendar function.
    9. As with the previous line of code, a similar line of code needs to be changed from
      $formated_date = (ICalEvents::format_date_range($event['StartTime'], $event['EndTime'], $event['Untimed'], $options['date_format'], $options['time_format']));

      to

      $formated_date = (ICalEvents::format_date_range(($event['StartTime']-3600), ($event['EndTime']-3600), $event['Untimed'], $options['date_format'], $options['time_format']));

    10. Save and close the cal-functions.php file.
    11. Finally, upload the modified files to replace the existing ones on your server.

    Alternatively, you could use the plugin editor to edit these files instead of downloading them and then uploading them.

    One downside to this approach is that it will most definitely break inthe Spring when daylight savings changes back, so you'll have to manually change things back. By then, I'm sure a better -more permanent- fix will be available.

  10. danatstadiumvolleyball
    Member
    Posted 2 weeks ago #

    This is great - thanks for taking the time to do this!

  11. careybradfield
    Member
    Posted 1 week ago #

    Wish this worked for me. My times seem to have jumped 2 hours rather than 1. Also, when I replaced the code from both function files, the popup window in my calendar stopped working altogether. When I removed the "-3600" from the function files, my popup windows still won't work.

    Is there any other way to fix the time issues?

  12. careybradfield
    Member
    Posted 1 week ago #

    I also noticed that my Local Server Time on the settings page for the ICS calendar displays the time 2 hours ahead.

  13. pjaxon
    Member
    Posted 4 days ago #

    Carey- Your case might be a little different. In my case, the server time was correct, but the displayed time in the plugin was wrong. It also sounds like something else may have been thrown off in your PHP since the popup windows don't work now. I'd try replacing your plugin files to get a fresh start again. Then, carefully edit those two lines of code that I mentioned above. In your case, you might need to use "- 7200" which is essentially how many seconds you want to adjust the displayed time.

    Hope that helps ~ pj

Reply

You must log in to post.

About this Topic