aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Zotlabs/Module/Channel_calendar.php9
-rw-r--r--include/event.php14
2 files changed, 17 insertions, 6 deletions
diff --git a/Zotlabs/Module/Channel_calendar.php b/Zotlabs/Module/Channel_calendar.php
index f83a0167d..5d5fe300a 100644
--- a/Zotlabs/Module/Channel_calendar.php
+++ b/Zotlabs/Module/Channel_calendar.php
@@ -27,9 +27,6 @@ class Channel_calendar extends \Zotlabs\Web\Controller {
if(($xchan) && ($xchan !== get_observer_hash()))
return;
- $timezone = ((x($_POST,'timezone_select')) ? escape_tags(trim($_POST['timezone_select'])) : '');
- $tz = (($timezone) ? $timezone : date_default_timezone_get());
-
$categories = escape_tags(trim($_POST['categories']));
// allday events have adjust = 0, normal events have adjust = 1
@@ -38,6 +35,12 @@ class Channel_calendar extends \Zotlabs\Web\Controller {
$start = datetime_convert((($adjust) ? $tz : 'UTC'), 'UTC', escape_tags($_REQUEST['dtstart']));
$finish = datetime_convert((($adjust) ? $tz : 'UTC'), 'UTC', escape_tags($_REQUEST['dtend']));
+ $timezone = ((x($_POST,'timezone_select')) ? escape_tags(trim($_POST['timezone_select'])) : '');
+ $tz = (($timezone) ? $timezone : date_default_timezone_get());
+
+ if(! $adjust)
+ $tz = 'UTC';
+
$summary = escape_tags(trim($_POST['summary']));
$desc = escape_tags(trim($_POST['desc']));
$location = escape_tags(trim($_POST['location']));
diff --git a/include/event.php b/include/event.php
index c8f9d2561..69ca64e0f 100644
--- a/include/event.php
+++ b/include/event.php
@@ -77,14 +77,22 @@ function format_event_obj($jobject) {
if(array_key_exists('description', $object)) {
$event_tz = '';
- if(is_array($object['asld']) && isset($object['asld']['attachment'])) {
+ if($object['adjust'] && is_array($object['asld']) && is_array($object['asld']['attachment'])) {
foreach($object['asld']['attachment'] as $attachment) {
if($attachment['type'] === 'PropertyValue' && $attachment['name'] == 'zot.event.timezone' ) {
- $event_tz = $attachment['value'];
+ // check if the offset of the timezones is different and only set event_tz if offset is not the same
+ $local_tz = new DateTimeZone(date_default_timezone_get());
+ $local_dt = new DateTime('now', $local_tz);
+
+ $ev_tz = new DateTimeZone($attachment['value']);
+ $ev_dt = new DateTime('now', $ev_tz);
+
+ if($local_dt->getOffset() !== $ev_dt->getOffset())
+ $event_tz = $attachment['value'];
+
break;
}
}
-
}
$allday = (($object['adjust']) ? false : true);