plugins/libkolab
Thomas Brüderli
bruederli at kolabsys.com
Wed May 23 15:40:09 CEST 2012
plugins/libkolab/lib/kolab_format.php | 8 ++++----
plugins/libkolab/lib/kolab_format_contact.php | 4 ++--
2 files changed, 6 insertions(+), 6 deletions(-)
New commits:
commit 7d1882ad7636c900232cbee369b4d702d0d9489f
Author: Thomas Bruederli <bruederli at kolabsys.com>
Date: Wed May 23 15:39:53 2012 +0200
Enforce local time for birthday and anniversary fields
diff --git a/plugins/libkolab/lib/kolab_format.php b/plugins/libkolab/lib/kolab_format.php
index 883eb7f..b6215e0 100644
--- a/plugins/libkolab/lib/kolab_format.php
+++ b/plugins/libkolab/lib/kolab_format.php
@@ -64,13 +64,13 @@ abstract class kolab_format
* Convert the given date/time value into a cDateTime object
*
* @param mixed Date/Time value either as unix timestamp, date string or PHP DateTime object
- * @param DateTimeZone The timezone the date/time is in. Use global default if empty
+ * @param DateTimeZone The timezone the date/time is in. Use global default if Null, local time if False
* @param boolean True of the given date has no time component
* @return object The libkolabxml date/time object
*/
public static function get_datetime($datetime, $tz = null, $dateonly = false)
{
- if (!$tz) $tz = self::$timezone;
+ if (!$tz && $tz !== false) $tz = self::$timezone;
$result = new cDateTime();
// got a unix timestamp (in UTC)
@@ -79,7 +79,7 @@ abstract class kolab_format
if ($tz) $datetime->setTimezone($tz);
}
else if (is_string($datetime) && strlen($datetime))
- $datetime = new DateTime($datetime, $tz);
+ $datetime = new DateTime($datetime, $tz ?: null);
if (is_a($datetime, 'DateTime')) {
$result->setDate($datetime->format('Y'), $datetime->format('n'), $datetime->format('j'));
@@ -89,7 +89,7 @@ abstract class kolab_format
if ($tz && $tz->getName() == 'UTC')
$result->setUTC(true);
- else if ($tz)
+ else if ($tz !== false)
$result->setTimezone($tz->getName());
}
diff --git a/plugins/libkolab/lib/kolab_format_contact.php b/plugins/libkolab/lib/kolab_format_contact.php
index d39b32e..d2634a0 100644
--- a/plugins/libkolab/lib/kolab_format_contact.php
+++ b/plugins/libkolab/lib/kolab_format_contact.php
@@ -233,9 +233,9 @@ class kolab_format_contact extends kolab_format
if (isset($object['freebusyurl']))
$this->obj->setFreeBusyUrl($object['freebusyurl']);
if (isset($object['birthday']))
- $this->obj->setBDay(self::get_datetime($object['birthday'], null, true));
+ $this->obj->setBDay(self::get_datetime($object['birthday'], false, true));
if (isset($object['anniversary']))
- $this->obj->setAnniversary(self::get_datetime($object['anniversary'], null, true));
+ $this->obj->setAnniversary(self::get_datetime($object['anniversary'], false, true));
if (!empty($object['photo'])) {
if ($type = rc_image_content_type($object['photo']))
More information about the commits
mailing list