Skip to content

Commit

Permalink
Use Horde_Date's timezone alias capabilites when importing events.
Browse files Browse the repository at this point in the history
  • Loading branch information
yunosh committed Apr 10, 2014
1 parent f3fe427 commit 22ea813
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 15 deletions.
31 changes: 17 additions & 14 deletions kronolith/lib/Event.php
Expand Up @@ -1117,27 +1117,30 @@ public function fromiCalendar($vEvent)
try {
$start = $vEvent->getAttribute('DTSTART');
$startParams = $vEvent->getAttribute('DTSTART', true);
// We don't support different timezones for different attributes,
// so use the DTSTART timezone for the complete event.
if (isset($startParams[0]['TZID'])) {
try {
// Check if the timezone name is supported by PHP natively.
new DateTimeZone($startParams[0]['TZID']);
$tzid = $startParams[0]['TZID'];
$this->timezone = $tzid;
} catch (Exception $e) {
}
}
if (!is_array($start)) {
// Date-Time field
$this->start = new Horde_Date($start, $tzid);
$this->start = new Horde_Date($start);
} else {
// Date field
$this->start = new Horde_Date(
array('year' => (int)$start['year'],
'month' => (int)$start['month'],
'mday' => (int)$start['mday']),
$tzid);
'mday' => (int)$start['mday'])
);
}
// We don't support different timezones for different attributes,
// so use the DTSTART timezone for the complete event.
if (isset($startParams[0]['TZID'])) {
// Horde_Date supports timezone aliases, so try that first.
$this->start->timezone = $startParams[0]['TZID'];
try {
// Check if the timezone name is supported by PHP natively.
new DateTimeZone($this->start->timezone);
$this->timezone = $tzid = $this->start->timezone;
} catch (Exception $e) {
// Reset to default timezone.
$this->start->timezone = null;
}
}
} catch (Horde_Icalendar_Exception $e) {
throw new Kronolith_Exception($e);
Expand Down
2 changes: 1 addition & 1 deletion kronolith/package.xml
Expand Up @@ -829,7 +829,7 @@
<package>
<name>Horde_Data</name>
<channel>pear.horde.org</channel>
<min>2.0.0</min>
<min>2.0.8</min>
<max>3.0.0alpha1</max>
<exclude>3.0.0alpha1</exclude>
</package>
Expand Down

0 comments on commit 22ea813

Please sign in to comment.