Jump to:

10979 Posts in 2722 Topics by 1815 members

All other Modules

SilverStripe Forums » All other Modules » Event Calendar - Google .ics import - Time Issues

Discuss all other Modules here.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Page: 1 2
Go to End
Author Topic: 7878 Views
  • Hankins
    Avatar
    Community Member
    11 Posts

    Event Calendar - Google .ics import - Time Issues Link to this post

    Hello,

    I am having a problem importing my Google Calendar(.ics) into the Event Calendar Module and displaying the correct time. I am using SS2.3.3 with the latest trunk build of the event calendar module (r82). Below is an excerpt from my _config file:

    Object::add_extension('LeftAndMain', 'CalendarScriptInit');
    DataObject::add_extension('SiteTree','CalendarSiteTree');
    Calendar::set_param('language','EN');
    Calendar::set_param('timezone', 'US-Eastern');
    CalendarDateTime::set_param('offset','-04:00');
    CalendarDateTime::set_date_format('dmy');
    CalendarDateTime::set_time_format('12');

    Currently, the events that are showing up on the page imported by the Event Calendar module are off by 4hours. I have attempted to modify the offset which should be correct for EST but it seems to have no affect on the imported .ics file. Below are links to the public calendar I am attempting to import:

    XML: http://www.google.com/calendar/feeds/6ba0alacitu7l8rm6tkt1hg7pk%40group.calendar.google.com/public/basic
    iCal: http://www.google.com/calendar/ical/6ba0alacitu7l8rm6tkt1hg7pk%40group.calendar.google.com/public/basic.ics
    xHTML: http://www.google.com/calendar/embed?src=6ba0alacitu7l8rm6tkt1hg7pk%40group.calendar.google.com&ctz=America/New_York

    Implementation: http://ruckuspizza.com/cary_nc/ruckus-events/

    I also just noticed a few other problems:

    Some events are not showing up at all
    When filtering the events, it still displays events not within the specified time frame.
    In the actual XML feed it appears that multiple timezones are being used such as EDT. I have reviewed the timezone in the google calendar settings and it is set correctly to Eastern Specific.

    I appreciate any input on this issue and will provide any additional details as needed.

    Thanks!
    Matt

  • UncleCheese
    Avatar
    4085 Posts

    Re: Event Calendar - Google .ics import - Time Issues Link to this post

    This is unfortunately one of the neglected features of EventCalendar due to lack of testers, so thanks for taking the time to kick the tires a bit.

    The events not being filtered properly was caused by a bug I had fixed, but realized I had never checked in. So if you update your SVN, you should get that fix.

    I have your ICS running on the demo site here http://eventcalendar.bluehousegroup.com/. Can you tell me what I should be looking for? Which times are wrong? What events are missing? I'll do my best to help you out.

  • Hankins
    Avatar
    Community Member
    11 Posts

    Re: Event Calendar - Google .ics import - Time Issues Link to this post

    Hi Uncle Cheese,

    Thank you for your time and assistance. I have been reading your previous post and appreciate the support you provide to the community.

    I have compiled a quick & dirty image displaying which events are not being shown in the calendar (indicated in pink) and which events are displayed but with the incorrect time (indicated in blue). It appears the times are off by -4 hours. The majority of the events that are not displayed are repeat events. I included an example of the full event details for both cases. I believe I mentioned before that I noticed different timezones in the RSS feed, below is an excerpt:

    Panthers v Tampa Ticket Giveaway
    Thursday, October 01, 2009 11:50 PM
    When: Sun Oct 18, 2009 1pm to 2:30pm EDT <---------------here

    Where: Ruckus Cary
    Event Status: confirmed
    Mims NCSU / UNC promotion
    Thursday, October 01, 2009 3:34 PM
    When: Sat Dec 5, 2009 12:30pm to 2:30pm EST <--------------- here

    I have been messing around with the calendar and can't quite figure out what is going on here. I look forward to hearing back from you and any help you can provide.

    Sincerely,
    Matt

    Attached Files
  • UncleCheese
    Avatar
    4085 Posts

    Re: Event Calendar - Google .ics import - Time Issues Link to this post

    This certainly raises a lot of questions. First thing I see is that the ICS is coming in with the wrong times, so this may be a Google setting we don't know about. You'll notice the Uroz wine tasting comes in with the times 4 hours off:

    BEGIN:VEVENT
    DTSTART:20091002T223000Z
    DTEND:20091003T003000Z
    DTSTAMP:20091002T164228Z
    UID:ubv83elp78mb6qq12acqh61hg4@google.com
    CREATED:20090923T190539Z
    DESCRIPTION:Come Sample Some Great Wines And Buy At A Wholesale Price!!!
    LAST-MODIFIED:20090928T081419Z
    LOCATION:Ruckus Cary
    SEQUENCE:0
    STATUS:CONFIRMED
    SUMMARY:Uroz Wine Tasting
    TRANSP:OPAQUE
    END:VEVENT

    Second thing is that the events that aren't showing up are getting cut because their start dates are our of range.

    Let's look at Smokin' Saturdays as an example:

    BEGIN:VEVENT
    DTSTART;VALUE=DATE:20090912
    DTEND;VALUE=DATE:20090913
    RRULE:FREQ=WEEKLY;BYDAY=SA;WKST=SU
    DTSTAMP:20091002T164228Z
    UID:6a9nfddoi3vi5ll0kpcc3dtubc@google.com
    CREATED:20090910T135546Z
    DESCRIPTION:
    LAST-MODIFIED:20091002T142506Z
    LOCATION:
    SEQUENCE:0
    STATUS:CONFIRMED
    SUMMARY:Smokin' Saturdays
    TRANSP:OPAQUE
    END:VEVENT

    It comes in with a start/end date in September instead of tomorrow.

    Also notice in your vCalendar header that there are two parameters for timezone:

    TZOFFSETFROM:-0400
    TZOFFSETTO:-0500

    That may have something to do with it.

    I don't have any answers, but at least we know we can fix it from within the feed.

  • coffeymachine
    Avatar
    Community Member
    10 Posts

    Re: Event Calendar - Google .ics import - Time Issues Link to this post

    The issue here is Google exports the time of all their events in UTC (GMT, Zulu, universal time, or whatever you want to call it) even though they specify the time zone in their .ics file. Don't ask me why.

    The solution is to offset their time by your local time offset. In event_calendar/code/CalendarUtil.php line 153 replace the function date_info_from_ics with this code:

    public static function date_info_from_ics($dtstart, $dtend)
       {
          $myOffset = '+1 hours';
          
          $startTimestamp = strtotime($dtstart.$myOffset);
          $start_date = date('Y-m-d', $startTimestamp);
          $start_time = date('H:i:s', $startTimestamp);
          
          $endTimestamp = strtotime($dtend.$myOffset);
          $end_date = date('Y-m-d', $endTimestamp);
          $end_time = date('H:i:s', $endTimestamp);

          return array($start_date, $end_date, $start_time, $end_time);   
       }

    Now the time offset works a little funny, I have to set "+1 hours" as the $myOffset variable to get Eastern Standard Time (-5 hours). I haven't had the time to dig into why it works like this, but this is a quick and dirty solution to this problem.

    This fix can definitely be improved. If we could get the time offset from the _config.php file that would be nice, or even use the time zone from Google's .ics file. I'll try to look into this if I get time. The big annoyance with this is that I am going to have to change the offset when daylight savings time comes around, and events visible on the calendar after a daylight savings time change will show the incorrect time.

  • coffeymachine
    Avatar
    Community Member
    10 Posts

    Re: Event Calendar - Google .ics import - Time Issues Link to this post

    Disregard the last paragraph I wrote if you are importing from Google Calendar. After a little testing this morning (my eyes were sore from staring at code last night) it turns out Google makes the DST shift for us in the .ics file. So if you are importing from Google my above solution will work just fine year-round.

    If you are importing from some calendar other than Google you should test this.

    I would still like to figure out how to get the time zone offset from _config.php.

  • sureshk
    Avatar
    Community Member
    10 Posts

    Re: Event Calendar - Google .ics import - Time Issues Link to this post

    Is there any way to import events from a CSV file? I need to import events from a CSV file.
    And also I need to import from ICS file instead of giving the url in CMS admin.

  • jseth
    Avatar
    Community Member
    98 Posts

    Re: Event Calendar - Google .ics import - Time Issues Link to this post

    Uncle Cheese,
    I'm having the same problem with the date being 5 hours ahead - the date of the event should be 8 pm on Dec 8th, but it is showing as 1:00 am on Dec 9th. I've imported the .ics from our GroupWise Master Calendar, and it works beautifully, but for the time offset being wrong. I did check the offset in the _config.php, but the .ics data remains unaffected. I also tried the code that coffeymachine suggested but it threw errors.
    I see there wasn't really a resolution other than that Google does compensate, but I'm not using Google. (I tried to attach the .ics file I'm using but got "server error".)

    "I would still like to figure out how to get the time zone offset from _config.php." - is this possible to correct?

    Thanks so much.

    7878 Views
Page: 1 2
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.