aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorMario <mario@mariovavti.com>2019-06-03 11:25:48 +0000
committerMario <mario@mariovavti.com>2019-06-03 13:27:16 +0200
commit66c6c6c7d1c87aa50ac0fe701505802110b8eecb (patch)
treeeabc52344259474066818a55fdcefa8a880e845f /include
parent6d2ab6a7d68ac8bb474344eeb1a3baa4cb7c3b99 (diff)
downloadvolse-hubzilla-66c6c6c7d1c87aa50ac0fe701505802110b8eecb.tar.gz
volse-hubzilla-66c6c6c7d1c87aa50ac0fe701505802110b8eecb.tar.bz2
volse-hubzilla-66c6c6c7d1c87aa50ac0fe701505802110b8eecb.zip
regard timezones in calendar import/export
(cherry picked from commit 5b4aa1afc2d3811aae93706299dfb5d5c703198f)
Diffstat (limited to 'include')
-rw-r--r--include/event.php27
1 files changed, 23 insertions, 4 deletions
diff --git a/include/event.php b/include/event.php
index de4e692b8..b1da2de8e 100644
--- a/include/event.php
+++ b/include/event.php
@@ -144,6 +144,12 @@ function format_event_ical($ev) {
if($ev['etype'] === 'task')
return format_todo_ical($ev);
+ $tz = get_iconfig($ev['item_id'], 'event', 'timezone');
+ if(! $tz)
+ $tz = 'UTC';
+
+ $tzid = ';TZID=' . $tz;
+
$o = '';
$o .= "\r\nBEGIN:VEVENT";
@@ -151,10 +157,19 @@ function format_event_ical($ev) {
$o .= "\r\nCREATED:" . datetime_convert('UTC','UTC', $ev['created'],'Ymd\\THis\\Z');
$o .= "\r\nLAST-MODIFIED:" . datetime_convert('UTC','UTC', $ev['edited'],'Ymd\\THis\\Z');
$o .= "\r\nDTSTAMP:" . datetime_convert('UTC','UTC', $ev['edited'],'Ymd\\THis\\Z');
- if($ev['dtstart'])
- $o .= "\r\nDTSTART:" . datetime_convert('UTC','UTC', $ev['dtstart'],'Ymd\\THis' . (($ev['adjust']) ? '\\Z' : ''));
- if($ev['dtend'] && ! $ev['nofinish'])
- $o .= "\r\nDTEND:" . datetime_convert('UTC','UTC', $ev['dtend'],'Ymd\\THis' . (($ev['adjust']) ? '\\Z' : ''));
+
+ if($ev['adjust']) {
+ if($ev['dtstart'])
+ $o .= "\r\nDTSTART$tzid:" . datetime_convert($tz,'UTC', $ev['dtstart'],'Ymd\\THis\\Z');
+ if($ev['dtend'] && ! $ev['nofinish'])
+ $o .= "\r\nDTEND$tzid:" . datetime_convert($tz,'UTC', $ev['dtend'],'Ymd\\THis\\Z');
+ }
+ else {
+ if($ev['dtstart'])
+ $o .= "\r\nDTSTART;VALUE=DATE:" . datetime_convert('UTC','UTC', $ev['dtstart'],'Ymd');
+ if($ev['dtend'] && ! $ev['nofinish'])
+ $o .= "\r\nDTEND;VALUE=DATE:" . datetime_convert('UTC','UTC', $ev['dtend'],'Ymd');
+ }
if($ev['summary']) {
$o .= "\r\nSUMMARY:" . format_ical_text($ev['summary']);
$o .= "\r\nX-ZOT-SUMMARY:" . format_ical_sourcetext($ev['summary']);
@@ -856,6 +871,10 @@ function event_import_ical($ical, $uid) {
$ev['external_id'] = $evuid;
}
+ $ev['timezone'] = 'UTC';
+ if(isset($ical->DTSTART['TZID']))
+ $ev['timezone'] = $ical->DTSTART['TZID'];
+
if($ev['summary'] && $ev['dtstart']) {
$ev['event_xchan'] = $channel['channel_hash'];
$ev['uid'] = $channel['channel_id'];