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
Support for DST in RRULES #109
Comments
I believe this may be related to #105 - I have a fix coming so if you could try that once I release |
Fixed by the release of |
I am not sure exactly what is wrong, but now after updating the library I am getting back these date/times:
The original google event is 8a-11a (America/New_York) FYI. |
|
Ok - getting closer. So now if I set However now my non-recurring event is now coming back with the incorrect time. The non-recurring event was in the sample ics I posted earlier and now it comes back with This is the code I use now based on what you sent me: $dtstart = new DateTime('@' . (int) $ical->iCalDateToUnixTimestamp($event->dtstart));
$start = $dtstart->format('Y-m-d H:i:s');
$dtend = new DateTime('@' . (int) $ical->iCalDateToUnixTimestamp($event->dtend));
$end = $dtend->format('Y-m-d H:i:s'); |
…lDateWithTimeZone()` unless Zulu time has been specified
$dtstart_tz = new DateTime('@' . (int) $ical->iCalDateToUnixTimestamp($event->dtstart_tz));
$start = $dtstart_tz->format('Y-m-d H:i:s');
$dtend_tz = new DateTime('@' . (int) $ical->iCalDateToUnixTimestamp($event->dtend_tz));
$end = $dtend_tz->format('Y-m-d H:i:s'); |
No difference this morning when I tried the updated code, changed to the new constructor and used the One question I do have - you mentioned for the non-recurring event 'do not finalise DTSTART / DTEND with Z'... What do you mean by that? Google is adding the Z (I included the link to the ics coming from google if you want to look at that)... Here is a more complete sample of my current code. There is one non-recurring event from 8a-9a and a M/W/F recurring from 8a-11a my time zone (EST). date_default_timezone_set('America/New_York');
ini_set("date.timezone", 'America/New_York');
$folder_id="https://calendar.google.com/calendar/ical/l0isqaou87j5hrha1eu2oac9jo%40group.calendar.google.com/public/basic.ics";
$ical = new ICal($folder_id, array(
'defaultSpan' => 2,
'defaultWeekStart' => 'MO',
'useTimeZoneWithRRules' => false,
));
$events = $ical->sortEventsWithOrder($ical->eventsFromInterval('3 days'));
$out='';
if ($events) {
foreach ($events as $event) {
$subject = $event->summary;
$id = $event->uid;
$dtstart = new DateTime('@' . (int) $ical->iCalDateToUnixTimestamp($event->dtstart)); // _tz here does not work
$start = $dtstart->format('Y-m-d H:i:s');
$dtend = new DateTime('@' . (int) $ical->iCalDateToUnixTimestamp($event->dtend)); // _tz here does not work
$end = $dtend->format('Y-m-d H:i:s');
$location = $event->location;
$out.= "<response>";
$out.= "<subject>$subject</subject>";
$out.= "<location>$location</location>";
$out.= "<dtstart>$start</dtstart>";
$out.= "<dtend>$end</dtend>";
$out.= "<id>$id</id>";
$out.= "<priority>0</priority>";
$out.= "</response>";
} //for each
}
echo $out; It currently produces this - you can see the recurring event is correct with the code above, but the non-recurring event has the incorrect time (not adjusted for time zone). I tried using the dtstart_tz / dtend_tz fields and that did not help and in fact did not work for the recurring event. <response>
<subject>test2</subject>
<location></location>
<dtstart>2017-03-21 12:00:00</dtstart>
<dtend>2017-03-21 13:00:00</dtend>
<id>uqnt090jvr0en3cqkctlj90qg8@google.com</id>
<priority>0</priority>
</response>
<response>
<subject>Scott recur mwf</subject>
<location></location>
<dtstart>2017-03-22 08:00:00</dtstart>
<dtend>2017-03-22 11:00:00</dtend>
<id>9huhq46274rrptseqtmp07al34@google.com</id>
<priority>0</priority>
</response> |
|
<response>
<subject>test2</subject>
<location></location>
<dtstart>2017-03-21 08:00:00</dtstart>
<dtend>2017-03-21 09:00:00</dtend>
<id>uqnt090jvr0en3cqkctlj90qg8@google.com</id>
<priority>0</priority>
</response>
<response>
<subject>Scott recur mwf</subject>
<location></location>
<dtstart>2017-03-22 08:00:00</dtstart>
<dtend>2017-03-22 11:00:00</dtend>
<id>9huhq46274rrptseqtmp07al34@google.com</id>
<priority>0</priority>
</response> |
Looks good now, thank you |
Spot anything else just let me know - realise this has been a slog but I appreciate your help in fine tuning the parser. |
I am downloading ics data from Google calendar and non-recurring events appear ok with the correct time, but recurring events are off by 1 hour. I am setting the timezone in my php and turning on
$useTimeZoneWithRRules
at least puts my times within 1 hour (with this set to false it was 6 hours off). Changing the time zones between EST and EST5EDT and America/New York makes no difference to the output (I tried passingfalse
to theiCalDateToUnixTimestamp
).So I am thinking either something is broken with the parsing of this Google calendar RRULES, or it needs a way to account for DST, or possibly I have to change a setting?
The text was updated successfully, but these errors were encountered: