markuspoerschke / iCal

iCal-creator for PHP
https://ical.poerschke.nrw
MIT License
1.12k stars 158 forks source link

Invalid TZID value or missing VTIMEZONE component (Europe/Paris) #612

Open ncavallini opened 3 months ago

ncavallini commented 3 months ago

Hello all, I'd like to add the timezone Europe/Zurich to my Calendar. I do the following:

$phpDateTimeZone = new PhpDateTimeZone('Europe/Zurich');
$timeZone = TimeZone::createFromPhpDateTimeZone(
    $phpDateTimeZone,
    new DateTimeImmutable('2023-05-01 00:00:00', $phpDateTimeZone),
    new DateTimeImmutable('2099-12-31 23:59:59', $phpDateTimeZone),
);
$events = [];
// generate all events here
$event = new Event();
$event->setOccurrence(
        new TimeSpan(
            new DateTime(new DateTimeImmutable("2024-05-21 10:00:00"), true),
            new DateTime(new DateTimeImmutable("2024-05-21 11:00:00"), true),
        );
// ...
$calendar = new Calendar($events);
$calendar->addTimeZone($timeZone);

When validating the iCal on the website https://icalendar.org/validator.html, I get the following errors (for all events): Invalid TZID value or missing VTIMEZONE component (Europe/Paris) [near line # 5] The strange thing is: Europe/Paris is never mentioned in my code! If I switch the boolean in the DateTime constructor to false, errors disappear but then my iCal clients use UTC.

Thank you all.