vobject icon indicating copy to clipboard operation
vobject copied to clipboard

timezone use

Open ger82 opened this issue 5 years ago • 4 comments

Hello, I understand that there is nothing to change on vobject. My question is what I must do or change on my code, when I want to use timezone correctly.

This ist my code:

include 'vobject/vendor/autoload.php';
 use	Sabre\VObject;

$calData = [];
$calendarAdress = ['icalendartest.ics'];

foreach($calendarAdress as $adress) {
	$calendar = VObject\Reader::read( file_get_contents($adress) );

	$today = new DateTime('today');
	$nextWeek = new DateTime('+7 days');
	$newVCalendar = $calendar->expand( $today, $nextWeek, new DateTimeZone('Europe/Berlin') );

	if(!empty($newVCalendar->vevent)){
		foreach($newVCalendar->vevent as $event) {
			$dtstart = new DateTime( (string)$event->dtstart );
			
			echo	(string)$dtstart->format('d-m-Y H:i'), " ",$dtend->format('d-m-Y H:i'), " ", (string)$event->summary ,"<br>";
		}
	}
}

ger82 avatar Mar 05 '19 09:03 ger82

I think I have the same problem. In my case i have a recurr event with value=date. The reader Import this not with the local timezone. The date is always in UTC and the expand goes wrong. Have you found a way to submit the right timezone?

svethi avatar Jun 21 '19 16:06 svethi

expand() strips all timezones and converts the objects to UTC. This is by design. I can understand the need for people who might want an option on expand() that does not strip timezones, but this is a new feature request and ideally you should send a PR for this.

evert avatar Jun 21 '19 17:06 evert

Sorry, but that is not the problem. I can handle that. For more details. I have a event with rrule and value=date DTSTART is in this case f.e. 20190611 with recurrence every day. The event has a until 20190620T220000Z witch means UTC and in Europe/Berlin is that 2019-06-21 00:00:00. This is correct. But the import set DTSTART to 2019-06-11 00:00:00 UTC and this is not correct. This should be the local timezone and translated to UTC 20190610T220000Z. Now I have a 2 hours delay. Do you understand the problem? Is there a way to set the timezone for the value=date import?

svethi avatar Jun 21 '19 17:06 svethi

Morning (Europe/Berlin) Evert,

I’ve found a bug in the vcalender ->expand. You create the new EventIterator with only 2 Parameters. So the given $timeZone has no effect. I added a null to the second position and now it works. I have send you a pull request or that. Could you confirm that?

Greetings

svethi avatar Jun 23 '19 08:06 svethi