Branch 'kolab-syncroton-2.2' - lib/kolab_sync_data_calendar.php lib/kolab_sync_data.php
Aleksander Machniak
machniak at kolabsys.com
Mon Jan 27 15:51:20 CET 2014
lib/kolab_sync_data.php | 14 +++++++++++++-
lib/kolab_sync_data_calendar.php | 5 ++++-
2 files changed, 17 insertions(+), 2 deletions(-)
New commits:
commit 5d075686b940a36c75b3c98a81c28e4470d24d08
Author: Aleksander Machniak <alec at alec.pl>
Date: Mon Jan 27 15:49:35 2014 +0100
Better handling of DateTime objects with _dateonly=true
diff --git a/lib/kolab_sync_data.php b/lib/kolab_sync_data.php
index b09bf68..3579a12 100644
--- a/lib/kolab_sync_data.php
+++ b/lib/kolab_sync_data.php
@@ -1199,7 +1199,18 @@ abstract class kolab_sync_data implements Syncroton_Data_IData
// convert to UTC if needed
if ($tz_name != 'UTC') {
- $date->setTimezone(new DateTimeZone('UTC'));
+ $utc = new DateTimeZone('UTC');
+ // safe dateonly object conversion to UTC
+ // note: _dateonly flag is set by libkolab e.g. for birthdays
+ if ($date->_dateonly) {
+ // avoid time change
+ $date = new DateTime($date->format('Y-m-d'), $utc);
+ // set time to noon to avoid timezone troubles
+ $date->setTime(12, 0, 0);
+ }
+ else {
+ $date->setTimezone($utc);
+ }
}
}
else {
@@ -1410,6 +1421,7 @@ abstract class kolab_sync_data implements Syncroton_Data_IData
$minute = $data['_start']->format('i');
$second = $data['_start']->format('s');
$exception->setTime($hour, $minute, $second);
+ $exception->_dateonly = false;
$ex = array(
'deleted' => 1,
diff --git a/lib/kolab_sync_data_calendar.php b/lib/kolab_sync_data_calendar.php
index 296c162..14b379a 100644
--- a/lib/kolab_sync_data_calendar.php
+++ b/lib/kolab_sync_data_calendar.php
@@ -211,6 +211,9 @@ class kolab_sync_data_calendar extends kolab_sync_data implements Syncroton_Data
if ($value && is_a($value, 'DateTime')) {
$date = clone $value;
if ($event['allday']) {
+ // need this for self::date_from_kolab()
+ $date->_dateonly = false;
+
if ($name == 'start') {
$date->setTime(0, 0, 0);
}
@@ -220,7 +223,7 @@ class kolab_sync_data_calendar extends kolab_sync_data implements Syncroton_Data
}
}
- // set this date for use in exceptions handling
+ // set this date for use in recurrence exceptions handling
if ($name == 'start') {
$event['_start'] = $date;
}
More information about the commits
mailing list