From e23fead4c49bd793b82b5e098741fa2f39c8efb6 Mon Sep 17 00:00:00 2001 From: Thomas Date: Wed, 28 Sep 2011 12:15:06 +0200 Subject: [PATCH] Make all-day events run from 12:00 - 13:00 to reduce timezone and dst problems --- plugins/calendar/calendar_ui.js | 20 +++++++++---------- .../calendar/drivers/kolab/kolab_calendar.php | 11 +++++----- 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/plugins/calendar/calendar_ui.js b/plugins/calendar/calendar_ui.js index c2598944..817d3317 100644 --- a/plugins/calendar/calendar_ui.js +++ b/plugins/calendar/calendar_ui.js @@ -458,8 +458,8 @@ function rcube_calendar_ui(settings) notify.checked = has_attendees(event), invite.checked = true; if (event.allDay) { - starttime.val("00:00").hide(); - endtime.val("23:59").hide(); + starttime.val("12:00").hide(); + endtime.val("13:00").hide(); allday.checked = true; } else { @@ -780,8 +780,8 @@ function rcube_calendar_ui(settings) freebusy_ui.endtime = $('#schedule-endtime').val($.fullCalendar.formatDate(event.end, settings['time_format'])).show(); if (allday.checked) { - freebusy_ui.starttime.val("00:00").hide(); - freebusy_ui.endtime.val("23:59").hide(); + freebusy_ui.starttime.val("12:00").hide(); + freebusy_ui.endtime.val("13:00").hide(); event.allDay = true; } @@ -1332,8 +1332,8 @@ function rcube_calendar_ui(settings) if (me.selected_event) { var allday = $('#edit-allday').get(0); me.selected_event.allDay = allday.checked; - me.selected_event.start = parse_datetime(allday.checked ? '00:00' : $('#edit-starttime').val(), $('#edit-startdate').val()); - me.selected_event.end = parse_datetime(allday.checked ? '23:59' : $('#edit-endtime').val(), $('#edit-enddate').val()); + me.selected_event.start = parse_datetime(allday.checked ? '12:00' : $('#edit-starttime').val(), $('#edit-startdate').val()); + me.selected_event.end = parse_datetime(allday.checked ? '13:00' : $('#edit-endtime').val(), $('#edit-enddate').val()); if (event_attendees) freebusy_ui.needsupdate = true; $('#edit-startdate').data('duration', Math.round((me.selected_event.end.getTime() - me.selected_event.start.getTime()) / 1000)); @@ -2237,13 +2237,13 @@ function rcube_calendar_ui(settings) if (event.end == null || event.end.getTime() < event.start.getTime()) { event.end = new Date(event.start.getTime() + (allDay ? DAY_MS : HOUR_MS)); } - // moved to all-day section: set times to 00:00 - 23:59 + // moved to all-day section: set times to 12:00 - 13:00 if (allDay && !event.allday) { - event.start.setHours(0); + event.start.setHours(12); event.start.setMinutes(0); event.start.setSeconds(0); - event.end.setHours(23); - event.end.setMinutes(59); + event.end.setHours(13); + event.end.setMinutes(0); event.end.setSeconds(0); } // moved from all-day section: set times to working hours diff --git a/plugins/calendar/drivers/kolab/kolab_calendar.php b/plugins/calendar/drivers/kolab/kolab_calendar.php index faa3c821..9ee32531 100644 --- a/plugins/calendar/drivers/kolab/kolab_calendar.php +++ b/plugins/calendar/drivers/kolab/kolab_calendar.php @@ -491,9 +491,10 @@ class kolab_calendar { $start_time = date('H:i:s', $rec['start-date']); $allday = $start_time == '00:00:00' && $start_time == date('H:i:s', $rec['end-date']); - if ($allday) { // in Roundcube all-day events only go until 23:59:59 of the last day - $rec['end-date']--; - $rec['end-date'] -= $this->cal->timezone * 3600 - date('Z', $rec['end-date']); // shift 00 times from server's timezone to user's timezone + if ($allday) { // in Roundcube all-day events only go from 12:00 to 13:00 + $rec['start-date'] += 12 * 3600; + $rec['end-date'] -= 11 * 3600; + $rec['end-date'] -= $this->cal->timezone * 3600 - date('Z', $rec['end-date']); // shift 00 times from server's timezone to user's timezone $rec['start-date'] -= $this->cal->timezone * 3600 - date('Z', $rec['start-date']); // because generated with mktime() in Horde_Kolab_Format_Date::decodeDate() // sanity check if ($rec['end-date'] <= $rec['start-date']) @@ -727,13 +728,13 @@ class kolab_calendar // whole day event if ($event['allday']) { - $object['end-date'] += 60; // end is at 23:59 => jump to the next day + $object['end-date'] += 12 * 3600; // end is at 13:00 => jump to the next day $object['end-date'] += $tz_offset - date('Z'); // shift 00 times from user's timezone to server's timezone $object['start-date'] += $tz_offset - date('Z'); // because Horde_Kolab_Format_Date::encodeDate() uses strftime() // sanity check: end date is same or smaller than start if (date('Y-m-d', $object['end-date']) <= date('Y-m-d', $object['start-date'])) - $object['end-date'] = mktime(0,0,0, date('n', $object['start-date']), date('j', $object['start-date']), date('Y', $object['start-date'])) + 86400; + $object['end-date'] = mktime(13,0,0, date('n', $object['start-date']), date('j', $object['start-date']), date('Y', $object['start-date'])) + 86400; $object['_is_all_day'] = 1; }