* Calendar: fix holidays are displayed one day off for eg. Austria, Slovakia, Australia (from iCloud)

Caused by no real floating date support in EGroupware and defaulting to UTC, if no timezone specified, because Horde_Icalendar does not report datetimes postfixed with Z as UTC.
Fixed now by not using UTC workaround for date (not datetime) values.
Also implemented default duration of one day for dtstart as date and no dtend/duration given.
This commit is contained in:
Ralf Becker 2016-11-05 12:00:19 +01:00
parent 6f978c6a07
commit cb6121c41f

View File

@ -1791,7 +1791,7 @@ class calendar_ical extends calendar_boupdate
{ {
// calendar_ical overrides search(), which breaks conflict checking // calendar_ical overrides search(), which breaks conflict checking
// so we make sure to use the original from parent // so we make sure to use the original from parent
static $bo; static $bo = null;
if(!$bo) if(!$bo)
{ {
$bo = new calendar_boupdate(); $bo = new calendar_boupdate();
@ -2478,12 +2478,7 @@ class calendar_ical extends calendar_boupdate
$dtstart_ts = is_numeric($attributes['value']) ? $attributes['value'] : $this->date2ts($attributes['value']); $dtstart_ts = is_numeric($attributes['value']) ? $attributes['value'] : $this->date2ts($attributes['value']);
$vcardData['start'] = $dtstart_ts; $vcardData['start'] = $dtstart_ts;
if ($this->tzid) // set event timezone from dtstart, if specified there
{
$event['tzid'] = $this->tzid;
}
else
{
if (!empty($attributes['params']['TZID'])) if (!empty($attributes['params']['TZID']))
{ {
// import TZID, if PHP understands it (we only care about TZID of starttime, // import TZID, if PHP understands it (we only care about TZID of starttime,
@ -2513,13 +2508,22 @@ class calendar_ical extends calendar_boupdate
$event['tzid'] = date_default_timezone_get(); // default to current timezone $event['tzid'] = date_default_timezone_get(); // default to current timezone
} }
} }
else // if no timezone given and one is specified in class (never the case for CalDAV)
elseif ($this->tzid)
{ {
$event['tzid'] = $this->tzid;
}
// Horde seems not to distinguish between an explicit UTC time postfixed with Z and one without // Horde seems not to distinguish between an explicit UTC time postfixed with Z and one without
// assuming for now UTC to pass CalDAVTester tests // assuming for now UTC to pass CalDAVTester tests
// ToDo: fix Horde_Icalendar to return UTC for timestamp postfixed with Z // ToDo: fix Horde_Icalendar to return UTC for timestamp postfixed with Z
elseif (!$isDate)
{
$event['tzid'] = 'UTC'; $event['tzid'] = 'UTC';
} }
// default to use timezone to better kope with floating time
else
{
$event['tzid'] = Api\DateTime::$user_timezone->getName();
} }
break; break;
@ -2553,6 +2557,13 @@ class calendar_ical extends calendar_boupdate
} }
return false; // not a valid entry return false; // not a valid entry
} }
// if neither duration nor dtend specified, default for dtstart as date is 1 day
if (!isset($vcardData['end']) && !$isDate)
{
$end = new Api\DateTime($vcardData['start']);
$end->add('1 day');
$vcardData['end'] = $end->format('ts');
}
// lets see what we can get from the vcard // lets see what we can get from the vcard
foreach ($component->getAllAttributes() as $attributes) foreach ($component->getAllAttributes() as $attributes)
{ {