texxasrulez / calendar

GNU Affero General Public License v3.0
15 stars 14 forks source link

Inaccurate date/time in interface #19

Open ner00 opened 3 years ago

ner00 commented 3 years ago

Roundcube correctly detects my timezone as GMT+00:00 (Europe/London), the VCalendar entries are grabbed correctly but then the interface shows the wrong date/time for event start/end. Here's an example:

BEGIN:VCALENDAR
VERSION:2.0
BEGIN:VEVENT
DTSTART;TZID=GMT Standard Time:20210428T090000
DTEND;TZID=GMT Standard Time:20210428T093000

Interface shows this as being scheduled from 10:00 to 10:30 (essentially adding +01:00 for no reason), but in the database it's correctly recorded as starting at 2021-04-28 09:00:00 and ending at 2021-04-28 09:30:00

Should I look somewhere in specific to fix this?

ner00 commented 3 years ago

function adjust_timezone from libcalendaring seems to be what's being used to incorrectly offset the time for me: $dt->setTimezone($this->timezone); Commenting the function keeps the correct time in the calendar overview but not in the detail (edit) window.

The code seems fine though, as does the content of $this->timezone

[timezone_type] => 3
[timezone] => Europe/London

In any case, there must be some reason why the date/time and timezone is fine everywhere but the event time still gets offset forward by 1 hour in the calendar view.

ner00 commented 3 years ago

Okay, so the problem seems two-fold:

  1. There is no DST awareness when the date/time is fed to adjust_timezone. The VCALENDAR entry has an explicit timezone of GMT, but no DST information. Not sure if that would be a standard piece of information or not.
  2. Beside no DST information, the entry's timzeone is sent incorrectly, I guess, since it should be GMT yet this is the content of $dt object sent to adjust_timezone function:
    [date] = > "2021-04-28 09:00:00.000000"
    [timezone_type] => 3
    [timezone] => "UTC"

    Because it receives UTC and/or no DST information, adjust_timezone will add the DST offset (+01:00) to an already DST-based timestamp. The event's start/end date, time, timezone, DST should all be validated before being passed on to adjust_timezone.