You are here

function date_ical_date in Date 7

Same name and namespace in other branches
  1. 5.2 date_api_ical.inc \date_ical_date()
  2. 5 date_api_ical.inc \date_ical_date()
  3. 6.2 date_api_ical.inc \date_ical_date()
  4. 6 date_api_ical.inc \date_ical_date()
  5. 7.3 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

4 calls to date_ical_date()
date_api_ical_build_rrule in date_api/date_api_ical.inc
Build an iCal RULE from $form_values.
date_repeat_build_dates in ./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/date_api_ical.inc, line 573
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();
  }
  else {
    $from_tz = $ical_date['tz'];
  }
  $date = new DateObject($ical_date['datetime'], new DateTimeZone($from_tz));
  if ($to_tz && $ical_date['tz'] != '' && $to_tz != $ical_date['tz']) {
    date_timezone_set($date, timezone_open($to_tz));
  }
  return $date;
}