Thanks again.
I also added:
$vobj = VObject\Reader::read($source);
$newVobj = $vobj->expand(new DateTime('2016-06-01'), new
DateTime('2017-12-31'));
as the ical has lots of recurring events.. I am hoping that it will also
handle the recurring event exceptions ( have yet to check that!)
Gus
On Wednesday, June 8, 2016 at 1:08:56 PM UTC-4, Evert Pot wrote:
>
> Great!
>
> Here's a small modification to make it a bit simpler even:
>
> On 2016-06-08 01:06 PM, Gus wrote:
> > This did it for me...Thanks for the help..
> > I hope it can be of use to other people:
> >
> > $source = file_get_contents('http://xyz.com/ical.ics');
> > $vobj = VObject\Reader::read($source);
> >
> > $item=array();
> > foreach($vobj->VEVENT as $data) {
> > $eventdate = $data->DTSTART->getDateTime()->format(\DateTime::W3C);;
> > $result['Date'] = date("l - M jS",strtotime($eventdate));
>
> Instead of those last two lines, you can just do:
>
> $result['Date'] = $data->DTSTART->getDateTime()->format('l - M jS');
>
>
>
> > $result['Schedule'] = (string)$data->SUMMARY;;
> > array_push($item,$result);
> > }
> > echo json_encode($item,JSON_PRETTY_PRINT);
> >
> > Gus
> >
> > On Wednesday, June 8, 2016 at 10:59:53 AM UTC-4, Evert Pot wrote:
> >
> >
> >
> > On 2016-06-08 7:12 AM, Gus wrote:
> > > Yes that worked! Thank you...
> > > However, having some difficulty as I am trying to convert to a
> > > 2-dimentional json by pulling 'summary' and 'dtstamp' only
> > >
> > > ~~~
> > > $source = file_get_contents('http://hostname/theicalfee.ics
> > <http://hostname/theicalfee.ics>'
> > > <http://hostname/theicalfee.ics <http://hostname/theicalfee.ics>'>);
>
> > > $vobj = VObject\Reader::read($source);
> > > $json = json_encode($vobj);
> > > $contdecode = json_decode($json);
> > >
> > > $item=array();
> > > foreach ( $contdecode['vevent'] as $value ) {
> > > $result['Date'] = date("l - M jS",strtotime($value['dtstart']))
> ;
> > > $result['Schedule'] = $value['summary'];
> > > array_push($item,$result);
> > > }
> > >
> > > echo json_encode($item,JSON_PRETTY_PRINT);
> >
> > Turning it into json and back doesn't make a lot of sense. The whole
> > point of vobject is that it helps you read iCalendar. Plus, you're
> > making a lot of assumptions about how the json structure actually
> looks
> > like. You should consider taking a look at the actual output of your
> > original json_encode.
> >
> > Regardless, you don't need these two lines:
> >
> > > $json = json_encode($vobj);
> > > $contdecode = json_decode($json);
> >
> > Just work with $vobj directly. There's a whole bunch of
> > documentation on
> > the site:
> >
> > http://sabre.io/vobject/icalendar/ <
> http://sabre.io/vobject/icalendar/>
> >
> > Evert
> >
>
--
You received this message because you are subscribed to the Google Groups
"SabreDAV Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/sabredav-discuss/9e05c6ee-c0b7-446d-aafe-78b6e4988399%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.