icalendar-generator icon indicating copy to clipboard operation
icalendar-generator copied to clipboard

Timezone '+01:00' does not work

Open juniwalk opened this issue 1 year ago • 0 comments

✏️ Describe the bug Hello, I have issue with timezones from PostgreSQL. Returned date has timezone '+01:00' instead of 'Europe/Prague', generated iCal using this DateTime instance does not work.

↪️ To Reproduce Provide us a test like this one which shows the problem:

$dtzA = new DateTimeZone('Europe/Prague');	// This works ok!
$dtzB = new DateTimeZone('+01:00');		// I get this from PostgreSQL using doctrine/orm and it does not work.

$startDate = new DateTime('now', $dtzA);
$endDate = new DateTime('+2 hours', $dtzB);

$cal = Calendar::create('Test');
$cal->event(Event::create('Hello, World!')
	->startsAt($startDate)
	->endsAt($endDate)
);
BEGIN:VCALENDAR
VERSION:2.0
PRODID:spatie/icalendar-generator
NAME:Test
X-WR-CALNAME:Test
BEGIN:VTIMEZONE
TZID:Europe/Prague
BEGIN:STANDARD
DTSTART:20231029T030000
TZOFFSETFROM:+0200
TZOFFSETTO:+0100
END:STANDARD
BEGIN:DAYLIGHT
DTSTART:20240331T010000
TZOFFSETFROM:+0100
TZOFFSETTO:+0200
END:DAYLIGHT
END:VTIMEZONE
BEGIN:VTIMEZONE
TZID:+01:00
BEGIN:STANDARD
DTSTART:20230601T111243
TZOFFSETFROM:+0000
TZOFFSETTO:+0000
END:STANDARD
END:VTIMEZONE
BEGIN:VTIMEZONE
TZID:UTC
BEGIN:STANDARD
DTSTART:20230601T081243
TZOFFSETFROM:+0000
TZOFFSETTO:+0000
END:STANDARD
END:VTIMEZONE
BEGIN:VEVENT
UID:65dc47fbe95ee
DTSTAMP:20240226T081243Z
SUMMARY:Hello\, World!
DTSTART;TZID=Europe/Prague:20240226T091243
DTEND;TZID=+01:00:20240226T111243
END:VEVENT
END:VCALENDAR

obrazek Output on: https://icalvalidator.com/index.html

Assertions aren't required, a simple dump or dd statement of what's going wrong is good enough 😄

✅ Expected behavior I would expect that TZ +01:00 would work the same way as if I set Europe/Prague.

🖥️ Versions

iCalendar generator: 2.6.0 PHP: 8.3.2

juniwalk avatar Feb 26 '24 08:02 juniwalk