Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

All other Modules /

Discuss all other Modules here.

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

Event Calendar - Google .ics import - Time Issues


Go to End


11 Posts   12631 Views

Avatar
jseth

Community Member, 98 Posts

10 December 2010 at 7:19am

To import an .ics, follow this link and read Uncle Cheese's post about ICS Feeds.

Avatar
kiwiot

Community Member, 8 Posts

1 February 2011 at 3:12am

I've had the same problem with timezones when importing a google ics. I tried coffeymachine's function which worked to some extent but meant that times were always shown even if the event was a full or multi-day event so I decided to write my own little hack by reformatting the original string.

I also came across a second issue. Google marks a full day event by an end date of the next day which in effect was causing my dates to show a day extra.

+ checks to see if the date is full/multiday and adjusts the end time by one day.
+ adds ability to offset timezone for events with times associated.

In event_calendar/code/CalendarUtil.php line 153 add the extra code to the function date_info_from_ics:


	 public static function date_info_from_ics($dtstart, $dtend)
	{
		
		$start_date = null;
		$end_date = null;
		$start_time = null;
		$end_time = null;
		
		/* Google Calendar ICS date hacks for timezone settings and full day events */

		$fulldaytest = explode("T",$dtstart);
		
		if(!isset($fulldaytest[1])) 
			$dtend = date('Ymd', strtotime($dtend.'-24 hours'));	
		
		else {
			$myOffset = '+9 hours'; // manual offset for Korea
			$startTimestamp = strtotime($dtstart.$myOffset);
			$dtstart = date('Ymd', $startTimestamp)."T".date('His', $startTimestamp)."Z";
			$endTimestamp = strtotime($dtend.$myOffset);
			$dtend = date('Ymd', $endTimestamp)."T".date('His', $endTimestamp)."Z";
		}
		
		/* END Google ICS hack */
		
		..... rest is the same as original function
	} 

Not too pretty but it'll do the job for now and I have not tested this thoroughly - so use at your own risk.

Hope this helps anyone else out there or at least puts you on the right track.

Regards,
Jared

Avatar
SerenityIT

Community Member, 13 Posts

12 May 2011 at 12:46am

Can't import any kind of ics into the calendar... It causes the page to go to error 500.

Go to Top