Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalid iCal generated when DateTimeZone is UTC #462

Closed
janpawellek opened this issue Nov 22, 2022 · 0 comments · Fixed by #482
Closed

Invalid iCal generated when DateTimeZone is UTC #462

janpawellek opened this issue Nov 22, 2022 · 0 comments · Fixed by #482
Labels

Comments

@janpawellek
Copy link

Code to reproduce:

$startDate = new DateTime();
$startDate->setTimezone(new \DateTimeZone('UTC'));
$endDate = new DateTime();
$endDate->setTimezone(new \DateTimeZone('UTC'));
$start = new \Eluceo\iCal\Domain\ValueObject\DateTime($startDate, true);
$end = new \Eluceo\iCal\Domain\ValueObject\DateTime($endDate, true);
$occurence = new \Eluceo\iCal\Domain\ValueObject\TimeSpan($start, $end);
$vEvent->setOccurrence($occurence);

This generates iCal that contains properties like this:

DTSTART;TZID=UTC:20220812T090000
DTEND;TZID=UTC:20220812T103000

However TZID=UTC is not allowed according to the specs: The "TZID" property parameter MUST NOT be applied to DATE properties and DATE-TIME or TIME properties whose time values are specified in UTC.

When this iCal export is passed to an iCal Validatior, it will fail with validation errors.

If I create the DateTime instace with $applyTimeZone = false:

$start = new \Eluceo\iCal\Domain\ValueObject\DateTime($startDate, false);
$end = new \Eluceo\iCal\Domain\ValueObject\DateTime($endDate, false);

This will create iCal without the "Z" suffix for UTC timestamps:

DTSTART:20220812T090000
DTEND:20220812T103000

Which results in wrong start and end times when imported into a calendar application.

I think the correct format shold look like this:

DTSTART:20220812T090000Z
DTEND:20220812T103000Z

Is there any option to get iCal properties like this?

Thank you!

markuspoerschke added a commit that referenced this issue Dec 25, 2022
Rather than setting TZID=UTC, date times that are using UTC must end
with the Z letter.

Wrong: DTSTART;TZID=UTC:20220812T090000
Correct: DTSTART;20220812T090000Z

Fixes: #462
Fixes: #263
markuspoerschke added a commit that referenced this issue Jan 17, 2023
Rather than setting TZID=UTC, date times that are using UTC must end
with the Z letter.

Wrong: DTSTART;TZID=UTC:20220812T090000
Correct: DTSTART;20220812T090000Z

Fixes: #462
Fixes: #263
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants