Skip to content

Google Calendar cannot import time zone description #53

Description

@dg76

Hi!

I am not sure if this is a new problem in Google Calendar but it seems now that it does not like the TZID in the time zone definition block when importing an ICS file generated by this library. The events of the ICS file are not displayed in Google Calendar if the time zone block looks like this:

BEGIN:VTIMEZONE
TZID:Europe/Berlin
BEGIN:STANDARD
DTSTART;TZID=+00:00:20201025T010000

It works fine when using an UTC time instead:

BEGIN:VTIMEZONE
TZID:Europe/Berlin
BEGIN:STANDARD
DTSTART:20201025T010000Z

The file CalendarExport.php creates the upper block in "local-tz" mode:

if ($this->dateTimeFormat === 'local') {
    ${$varName}['start'] = ':' . $this->formatter->getFormattedDateTime(new \DateTime($transition['time']));
} else if ($this->dateTimeFormat === 'utc') {
    ${$varName}['start'] = ':' . $this->formatter->getFormattedUTCDateTime(new \DateTime($transition['time']));
} else if ($this->dateTimeFormat == 'local-tz') {
    ${$varName}['start'] = ';' . $this->formatter->getFormattedDateTimeWithTimeZone(new \DateTime($transition['time']));
}

I would suggest to use the same mode as in "utc" to fix this:

if ($this->dateTimeFormat === 'local') {
    ${$varName}['start'] = ':' . $this->formatter->getFormattedDateTime(new \DateTime($transition['time']));
} else if ($this->dateTimeFormat === 'utc') {
    ${$varName}['start'] = ':' . $this->formatter->getFormattedUTCDateTime(new \DateTime($transition['time']));
} else if ($this->dateTimeFormat == 'local-tz') {
    ${$varName}['start'] = ':' . $this->formatter->getFormattedUTCDateTime(new \DateTime($transition['time']));
}

What do you think? Or is there a reason why getFormattedDateTimeWithTimeZone was used instead?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions