diff --git a/plugins/calendar/calendar.php b/plugins/calendar/calendar.php index f24a81ae..37e86a43 100644 --- a/plugins/calendar/calendar.php +++ b/plugins/calendar/calendar.php @@ -2924,11 +2924,11 @@ class calendar extends rcube_plugin $append = ''; // prepare a small agenda preview to be filled with actual event data on async request - if ($ical_objects->method == 'REQUEST') { + if ($ical_objects->method == 'REQUEST' && $event['start']) { + $date = $this->rc->format_date($event['start'], $this->rc->config->get('date_format'), empty($event['start']->_dateonly)); $append = html::div('calendar-agenda-preview', - html::tag('h3', 'preview-title', $this->gettext('agenda') . ' ' . - html::span('date', $this->rc->format_date($event['start'], $this->rc->config->get('date_format'))) - ) . '%before%' . $this->mail_agenda_event_row($event, 'current') . '%after%'); + html::tag('h3', 'preview-title', $this->gettext('agenda') . ' ' . html::span('date', $date)) + . '%before%' . $this->mail_agenda_event_row($event, 'current') . '%after%'); } $html .= html::div('calendar-invitebox invitebox boxinformation', diff --git a/plugins/libcalendaring/libcalendaring.php b/plugins/libcalendaring/libcalendaring.php index 6c33aba1..e9a4c286 100644 --- a/plugins/libcalendaring/libcalendaring.php +++ b/plugins/libcalendaring/libcalendaring.php @@ -315,8 +315,8 @@ class libcalendaring extends rcube_plugin $time_format = self::to_php_date_format($this->rc->config->get('calendar_time_format', $this->defaults['calendar_time_format'])); if ($event['allday']) { - $fromto = $this->rc->format_date($event['start'], $date_format); - if (($todate = $this->rc->format_date($event['end'], $date_format)) != $fromto) + $fromto = $this->rc->format_date($event['start'], $date_format, false); + if (($todate = $this->rc->format_date($event['end'], $date_format, false)) != $fromto) $fromto .= ' - ' . $todate; } else if ($duration < 86400 && $event['start']->format('d') == $event['end']->format('d')) { diff --git a/plugins/libcalendaring/libvcalendar.php b/plugins/libcalendaring/libvcalendar.php index b5e5e5a9..4f53494a 100644 --- a/plugins/libcalendaring/libvcalendar.php +++ b/plugins/libcalendaring/libvcalendar.php @@ -430,7 +430,7 @@ class libvcalendar implements Iterator case 'DTEND': case 'DUE': $propmap = array('DTSTART' => 'start', 'DTEND' => 'end', 'DUE' => 'due'); - $event[$propmap[$prop->name]] = self::convert_datetime($prop); + $event[$propmap[$prop->name]] = self::convert_datetime($prop); break; case 'TRANSP': @@ -694,16 +694,14 @@ class libvcalendar implements Iterator // assign current timezone to event start/end if ($event['start'] instanceof DateTime) { - if ($this->timezone) - $event['start']->setTimezone($this->timezone); + $this->_apply_timezone($event['start']); } else { unset($event['start']); } if ($event['end'] instanceof DateTime) { - if ($this->timezone) - $event['end']->setTimezone($this->timezone); + $this->_apply_timezone($event['end']); } else { unset($event['end']); @@ -728,6 +726,27 @@ class libvcalendar implements Iterator return $event; } + /** + * Apply user timezone to DateTime object + */ + private function _apply_timezone(&$date) + { + if (empty($this->timezone)) { + return; + } + + // For date-only we'll keep the date and time intact + if ($date->_dateonly) { + $dt = new DateTime(null, $this->timezone); + $dt->setDate($date->format('Y'), $date->format('n'), $date->format('j')); + $dt->setTime($date->format('G'), $date->format('i'), 0); + $date = $dt; + } + else { + $date->setTimezone($this->timezone); + } + } + /** * Parse the given vfreebusy component into an array representation */ @@ -816,7 +835,6 @@ class libvcalendar implements Iterator if (empty($prop)) { return $as_array ? array() : null; } - else if ($prop instanceof VObject\Property\iCalendar\DateTime) { if (count($prop->getDateTimes()) > 1) { $dt = array();