You are here

function date_ical_date in Date 5.2

Same name and namespace in other branches
  1. 5 date_api_ical.inc \date_ical_date()
  2. 6.2 date_api_ical.inc \date_ical_date()
  3. 6 date_api_ical.inc \date_ical_date()
  4. 7.3 date_api/date_api_ical.inc \date_ical_date()
  5. 7 date_api/date_api_ical.inc \date_ical_date()
  6. 7.2 date_api/date_api_ical.inc \date_ical_date()

Return a date object for the ical date, adjusted to its local timezone.

Parameters

$ical_date: an array of ical date information created in the ical import. @param $to_tz the timezone to convert the date's value to. @return object a timezone-adjusted date object

5 calls to date_ical_date()
date_api_ical_build_rrule in ./date_api_ical.inc
Build an iCal RULE from $form_values.
date_copy_import_ical_form_submit in date_copy/date_copy.module
date_repeat_build_dates in date/date_repeat.inc
Helper function to build repeating dates from a $node_field.
date_repeat_rrule_description in date_repeat/date_repeat.module
Build a description of an iCal rule.
_date_repeat_calc in date_repeat/date_repeat_calc.inc
Private implementation of date_repeat_calc().

File

./date_api_ical.inc, line 558
Parse iCal data.

Code

function date_ical_date($ical_date, $to_tz = FALSE) {

  // If the ical date has no timezone, must assume it is stateless
  // so treat it as a local date.
  if (empty($ical_date['datetime'])) {
    return NULL;
  }
  elseif (empty($ical_date['tz'])) {
    $from_tz = date_default_timezone_name();
  }
  else {
    $from_tz = $ical_date['tz'];
  }
  $date = date_make_date($ical_date['datetime'], $from_tz);
  if ($to_tz && $ical_date['tz'] != '' && $to_tz != $ical_date['tz']) {
    date_timezone_set($date, timezone_open($to_tz));
  }
  return $date;
}