u01jmg3 / ics-parser

Parser for iCalendar Events • PHP 8+, 7 (≥ 7.4), 5 (≥ 5.6)
MIT License
451 stars 145 forks source link

Problem with iCal calendar that shows times wrong #208

Closed machfr closed 5 years ago

machfr commented 5 years ago

I am having an issue where I have this Ical (Icloud): https://p59-calendars.icloud.com/published/2/NTU4MDkwODI4NTU4MDkwOFQqNMVtnNFS5S6Msuf6RmTzb4vQHQEI-ztPF8YDoroopzBpaSwui-TIyZju7LexUnrUXMiTuteNl2iNgttSYQ8

and on the 12th (today) I have en even running from 09:30 - 10:15 but when it comes out through the parser the dtstart_tz is set to 10:30 and dtend_tz to 11:15 which is 1 hour wrong.

I have tried to do the same with other calendars created in google, outlook and other places and they all get dtstart_tz and dtend_tz set correctly

the config is set as the follow:

$ical = new ICal($calendar_url, array(
    'defaultSpan'                 => 2,
    'defaultWeekStart'            => 'MO',
    'disableCharacterReplacement' => false,
    'filterDaysAfter'             => null,
    'filterDaysBefore'            => 1,
    'replaceWindowsTimeZoneIds'   => false,
    'useTimeZoneWithRRules'       => true,
));

someone able to maybe give me a hint on what is going wrong?

machfr commented 5 years ago

Screenshot 2019-03-12 at 12 58 56

Could maybe add that this shows that dtstart_array has the correct time where dtstart_tz dosen't, just to show you what the output from the parser gives as it might make it easier to give feedback on it.

u01jmg3 commented 5 years ago

Will try and find time this weekend to take a look but please proceed with your own investigation meantime. I don't get a lot of time to work on issues these days.

machfr commented 5 years ago

Ok, so I have found out that it goes wrong when you do this around line 1048:

$dateTime = new \DateTime($dateArray[1], new \DateTimeZone(self::TIME_ZONE_UTC));
$dateTime->setTimezone(new \DateTimeZone($this->calendarTimeZone()));

Where you take the time that stands as 9:30 and say it is UTC aka. UK time then after you set the timezone to Europe/Copenhagen which makes the time go one hour head compared to what it should be.