You are here

function date_ical_date in Date 5

Same name and namespace in other branches
  1. 5.2 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()

Adjust ical date to appropriate timezone and format it.

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

1 call to date_ical_date()
date_copy_import_ical_form_submit in ./date_copy.module

File

./date_api_ical.inc, line 493
Parse iCal imports and create iCal exports. This file must be included when these functions are needed.

Code

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

  // If the ical date has no timezone, must assume it is stateless
  $from_tz = $ical_date['tz'];

  // Convert this to an ISO date;
  $ical_date['datetime'] = str_replace(' ', 'T', $ical_date['datetime']);
  $date = date_make_date($ical_date['datetime'], $from_tz, 'local');
  if ($ical_date['tz'] != '' && $to_tz != $ical_date['tz']) {
    date_convert_timezone($date, $from_tz, $to_tz, 'local');
  }
  return $date;
}