Plugin Author
anmari
(@anmari)
Hi Travis,
ooooh timezones, guaranteed to confuse people no end…
short answer:
Yes, plugin converts to website timezone – very thoroughly tested (image daylight saving etc)
Yes, you can set the page to display in a timezone of your choice with a shortcode parameter:
http://icalevents.com/3521-how-event-timezones-work/
All events displayed with that shortcode will display in that timezone then. YOu can add a timezone switcher icon to the calendar properties to be displayed so folks can switch timezones if they want.
However it does NOT currently do a dummy type – just list what the ics file says, potentially having mixed timezones in one listing. Reason for this is that some ics files just list everything in UTC time, so to get events to what people ‘expect’ timezone conversion must be done.
Also mixing timezones on one page is confusing.
That said, many of the ‘formatting’ functions are pluggable, so you could write your own to display events (assuming mixed timezones in the ics file) in their ics timezone, clearly indicating the timezone so people don’t get confused.
Hmm – maybe it could be ‘extra option’ to display multiple times (one set in website time and one in original ics event time.)
more info : http://icalevents.com/?s=timezones
These are almost exclusively all-day events that are occurring in multiple time zones and are viewed in multiple time zones, so the ideal option is to just show the event according to the event timezone. I did this by adding a filter on amr_events_after_sort that will convert everything to the local time of the WordPress installation. In case anybody is interested, here’s the code:
function ConvertEventToLocalTime( $events ) {
$localTZName = get_option('timezone_string');
// All of our offset operations are in seconds
$localOffset = get_option('gmt_offset') * 3600;
// The timezone string can be empty if the timezone was set as a UTC offset,
// in which case we will derive it from the offset.
if('' == $localTZName) {
$localTZName = timezone_name_from_abbr('', $localOffset, date('I'));
// If we still couldn't obtain the local timezone then don't convert
if(false === $localTZName) {
return $events;
}
}
$localTZ = new DateTimeZone($localTZName);
foreach ($events as $event) {
if (isset ($event['EventDate']) and (is_object ($event['EventDate']))) {
$dt = $event['EventDate'];
// Determine the time difference between the event timezone and
// the local timezone. DateTime->getOffset returns the offset
// in seconds, whereas the gmt_offset option is in hours.
$secondsToAdd = $dt->getOffset() - $localOffset;
$interval = new DateInterval('PT'.abs($secondsToAdd).'S');
// Change the timezone. This will NOT change the UTC time.
$dt->SetTimezone($localTZ);
// Adjust the UTC time so that the relative time is the same.
$secondsToAdd > 0 ? $dt->add($interval) : $dt->sub($interval);
}
}
return $events;
}
add_filter( 'amr_events_after_sort', 'ConvertEventToLocalTime' );