org_heigl/calendar-aggregator

Aggregate iCalendar and CalDav calendars

0.2.0 2017-03-29 19:44 UTC

This package is auto-updated.

Last update: 2024-12-23 10:21:56 UTC


README

Aggregate iCalendar and CalDav calendars

Usage

$aggregator = new Aggregator();
$aggregator->add(new Icalendar('https://example.com/icalendar'));
// $aggregator->add(new CalDav('https://example.com/caldav'));

$range = $aggregator->getRange(
    new DateTimeImmutable('2017-01-01'), 
    new DateTimeImmutable('2018-01-01')
);

foreach ($range as $event) {
    echo sprintf(
        'Event %s starts %s and ends %s',
        $event->getTitle,
        $event->getStart()->format('c'),
        $event->getEnd()->format('c')
    );
}

Alternatively you can also retrieve the events in "lanes" where each lane contains a list of non-overlapping events.

$aggregator = new Aggregator();
$aggregator->add(new Icalendar('https://example.com/icalendar'));
// $aggregator->add(new CalDav('https://example.com/caldav'));

$range = $aggregator->getRange(
    new DateTimeImmutable('2017-01-01'), 
    new DateTimeImmutable('2018-01-01')
);

foreach ($range->getLanes() as $lane) {
    foreach ($lane as $event) {
        echo sprintf(
            'Event %s starts %s and ends %s',
            $event->getTitle,
            $event->getStart()->format('c'),
            $event->getEnd()->format('c')
        );
    }
}