You are here

function hook_date_ical_import_timezone_alter in Date iCal 7.3

Alter the timezone string from an imported iCal Feed.

This is useful for when an iCal feed you're trying to import uses deprecated timezone names, like "Eastern Standard Time" rather than "America/New_York", or has date values with missing timezone information.

Parameters

string $tzid: The timezone id sting to be altered (e.g. "America/Los_Angeles"). If this value is NULL, not timezone id was set in the feed.

array $context: An associative array of context, with the following keys and values:

  • 'property_key': The name of the property (e.g. DTSTART). Can be NULL.
  • 'calendar_component': The iCalcreator object (e.g VEVENT). Can be NULL.
  • 'calendar': The iCalcreater vcalendar object created from the feed.
  • 'feeds_source': A FeedsSource object with this feed's metadata.
  • 'feeds_detcher_result': The FeedsFeatcherResult for this import.

If property_key and calendar_component are NULL, this is the X-WR-TIMEZONE string for the entire feed.

2 invocations of hook_date_ical_import_timezone_alter()
ParserVcalendar::parse in libraries/ParserVcalendar.inc
Parses the vcalendar object into an array of event data arrays.
ParserVcalendar::parseDateTimeProperty in libraries/ParserVcalendar.inc
Handler that parses DATE-TIME and DATE fields.

File

./date_ical.api.php, line 216
Documentation for the hooks provided by Date iCal.

Code

function hook_date_ical_import_timezone_alter(&$tzid, $context) {

  // Example of what might be done with this alter hook:
  if ($tzid == 'Eastern Standard Time') {

    // "Eastern Standard Time" is a deprecated tzid, which PHP doesn't accept.
    // However, it's equivalent to "America/New_York", which PHP is fine with.
    $tzid = 'America/New_York';
  }
}