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

VTimezone: DAYLIGHT and STANDARD in the same timezone #317

Open
roelmonnens opened this issue Apr 26, 2016 · 3 comments

Comments

@roelmonnens
Copy link

commented Apr 26, 2016

Hey,
When I put DAYLIGHT and STANDARD in de same timezone like this:

$vcalendar         = new VCalendar();
$vcalendar->PRODID = 'test';

$vtimezone = $vcalendar->add('VTIMEZONE', [
    'TZID'           => 'Europe/Brussels',
    'X-LIC-LOCATION' => 'Europe/Brussels'
]);
$vtimezone->add('BEGIN', 'STANDARD');
$vtimezone->add('TZOFFSETFROM', '+0200');
$vtimezone->add('TZOFFSETTO', '+0100');
$vtimezone->add('TZNAME', 'CET');
$vtimezone->add('DTSTART', (new \DateTime('1970-10-25 03:00:00', new \DateTimeZone('Europe/Brussels')))->format('Ymd\THis'));
$vtimezone->add('RRULE', 'FREQ=YEARLY;BYMONTH=10;BYDAY=-1SU');
$vtimezone->add('END', 'STANDARD');

$vtimezone->add('BEGIN', 'DAYLIGHT');
$vtimezone->add('TZOFFSETFROM', '+0100');
$vtimezone->add('TZOFFSETTO', '+0200');
$vtimezone->add('TZNAME', 'CEST');
$vtimezone->add('DTSTART', (new \DateTime('1970-03-29 02:00:00', new \DateTimeZone('Europe/Brussels')))->format('Ymd\THis'));
$vtimezone->add('RRULE', 'FREQ=YEARLY;BYMONTH=3;BYDAY=-1SU');
$vtimezone->add('END', 'DAYLIGHT');
echo $vcalendar->serialize();

I get this result:

BEGIN:VCALENDAR 
VERSION:2.0 
CALSCALE:GREGORIAN 
PRODID:test
BEGIN:VTIMEZONE 
TZID:Europe/Brussels 
X-LIC-LOCATION:Europe/Brussels 
BEGIN:DAYLIGHT 
BEGIN:STANDARD
TZOFFSETFROM:+0100 
TZOFFSETFROM:+0200 
TZOFFSETTO:+0200 
TZOFFSETTO:+0100 
TZNAME:CEST TZNAME:CET 
DTSTART:19700329T020000 
DTSTART:19701025T030000 
RRULE:FREQ=YEARLY;BYMONTH=3;BYDAY=-1SU 
RRULE:FREQ=YEARLY;BYMONTH=10;BYDAY=-1SU 
END:DAYLIGHT 
END:STANDARD
END:VTIMEZONE 
END:VCALENDAR

Notice
BEGIN:DAYLIGHT
BEGIN:STANDARD

This should actually be:

BEGIN:VCALENDAR 
VERSION:2.0 
CALSCALE:GREGORIAN 
PRODID:test
BEGIN:VTIMEZONE 
TZID:Europe/Brussels 
X-LIC-LOCATION:Europe/Brussels 
BEGIN:STANDARD 
TZOFFSETFROM:+0200 
TZOFFSETTO:+0100  
TZNAME:CET 
DTSTART:19701025T030000 
RRULE:FREQ=YEARLY;BYMONTH=10;BYDAY=-1SU 
END:STANDARD
BEGIN:DAYLIGHT
TZOFFSETFROM:+0100 
TZOFFSETTO:+0200 
TZNAME:CEST
DTSTART:19700329T020000 
RRULE:FREQ=YEARLY;BYMONTH=3;BYDAY=-1SU 
END:DAYLIGHT
END:VTIMEZONE 
END:VCALENDAR

In Component/VTimeZone I have found this comment:

// At least 1 STANDARD or DAYLIGHT must appear, or more. But both
// cannot appear in the same VTIMEZONE.

Is there another way to add DAYLIGHT and STANDARD to a timezone. And why should both not appear in the same VTIMEZONE?

The rfc states that they are OPTIONAL and MAY occur more than once.
rfc-5545

Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

evert added a commit that referenced this issue Apr 26, 2016

@evert

This comment has been minimized.

Copy link
Member

commented Apr 26, 2016

Hi!

I updated the docblock, you were correct that they can both appear in a vtimezone.

As for your other problem, I realized that there's something missing in sabre/vobject that prevents you from easily setting this up. You are currently treating the BEGIN:STANDARD and END:STANDARD as properties with the names BEGIN and END, but this is wrong.

Normally you should just be able to call:

$vtimezone->add('STANDARD', [
   'TZOFFSETFROM' => '+0200',
   /*** etc **/ 
]);

But something is missing to make this work! Workaround until I've fixed this:

$standard = $vtimezone->createComponent('STANDARD', [
   'TZOFFSETFROM' => '+0200',
   /*** etc **/ 
]);

$vtimezone->add($standard);

Here we explicitly tell vobject to create a component with name STANDARD and pass one or more properties.

After that it's still needed to call add on $vtimezone, because we only created the component, but didn't insert it anywhere in the document.

@roelmonnens

This comment has been minimized.

Copy link
Author

commented Apr 27, 2016

Thnx
Workaround works fine!

@saulojg

This comment has been minimized.

Copy link

commented Aug 15, 2016

Maybe this issue should be mentioned on the documentation at http://sabre.io/vobject/usage_2/, Date and time handling section. Aside of the coexistence issue with DAYLIGHT and TIMEZONE, we currently cannot declare a TIMEZONE block the way it's supposed to be (without $vtimezone->add('BEGIN', ... )).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.