aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMario <mario@mariovavti.com>2019-06-03 13:25:48 +0200
committerMario <mario@mariovavti.com>2019-06-03 13:25:48 +0200
commit5b4aa1afc2d3811aae93706299dfb5d5c703198f (patch)
treea7b870e2703d8b61356564df8018a5f0d36eb9eb
parent89205276ab7642be3a4afacd9b613ff006f7ede3 (diff)
downloadvolse-hubzilla-5b4aa1afc2d3811aae93706299dfb5d5c703198f.tar.gz
volse-hubzilla-5b4aa1afc2d3811aae93706299dfb5d5c703198f.tar.bz2
volse-hubzilla-5b4aa1afc2d3811aae93706299dfb5d5c703198f.zip
regard timezones in calendar import/export
-rw-r--r--Zotlabs/Module/Channel_calendar.php4
-rw-r--r--include/event.php27
2 files changed, 26 insertions, 5 deletions
diff --git a/Zotlabs/Module/Channel_calendar.php b/Zotlabs/Module/Channel_calendar.php
index 13f879d84..4f08eb27c 100644
--- a/Zotlabs/Module/Channel_calendar.php
+++ b/Zotlabs/Module/Channel_calendar.php
@@ -304,7 +304,9 @@ class Channel_calendar extends \Zotlabs\Web\Controller {
);
}
elseif($export) {
- $r = q("SELECT * from event where uid = %d and dtstart > '%s' and dtend > dtstart",
+ $r = q("SELECT event.*, item.id as item_id
+ from event left join item on item.resource_id = event.event_hash
+ where event.uid = %d and event.dtstart > '%s' and event.dtend > event.dtstart",
intval(local_channel()),
dbesc(NULL_DATE)
);
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'];