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

timezone use #448

Open
ger82 opened this issue Mar 5, 2019 · 4 comments
Open

timezone use #448

ger82 opened this issue Mar 5, 2019 · 4 comments

Comments

@ger82
Copy link

@ger82 ger82 commented Mar 5, 2019

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>";
		}
	}
}
@svethi

This comment has been minimized.

Copy link
Contributor

@svethi svethi commented Jun 21, 2019

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?

@evert

This comment has been minimized.

Copy link
Member

@evert evert commented Jun 21, 2019

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.

@svethi

This comment has been minimized.

Copy link
Contributor

@svethi svethi commented Jun 21, 2019

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

This comment has been minimized.

Copy link
Contributor

@svethi svethi commented Jun 23, 2019

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

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.