コード例 #1
0
          </summary>
        </properties>
      </vevent>
    </components>
  </vcalendar>
</icalendar>
EOF;
$e = kolabformat::readEvent($xml, false);
$ec = new EventCal($e);
$rstart = new cDateTime(2012, 8, 1, 0, 0, 0);
# asserttrue($ec->getNextOccurence($rstart) instanceof cDateTime, "EventCal::getNextOccurence() returning cDateTime instance");
$next = new cDateTime($ec->getNextOccurence($rstart));
assertequal(sprintf("%d-%d-%d %02d:%02d:%02d", $next->year(), $next->month(), $next->day(), $next->hour(), $next->minute(), $next->second()), "2012-10-23 14:00:00", "EventCal first recurrence");
$next = new cDateTime($ec->getNextOccurence($next));
assertequal(sprintf("%d-%d-%d %02d:%02d:%02d", $next->year(), $next->month(), $next->day(), $next->hour(), $next->minute(), $next->second()), "2012-10-25 14:00:00", "EventCal second recurrence");
$end = new cDateTime($ec->getOccurenceEndDate($next));
assertequal(sprintf("%d-%d-%d %02d:%02d:%02d", $end->year(), $end->month(), $end->day(), $end->hour(), $end->minute(), $end->second()), "2012-10-25 15:30:00", "EventCal::getOccurenceEndDate");
$last = new cDateTime($ec->getLastOccurrence());
assertequal(sprintf("%d-%d-%d %02d:%02d:%02d", $last->year(), $last->month(), $last->day(), $last->hour(), $last->minute(), $last->second()), "2012-10-29 14:00:00", "EventCal::getLastOccurence");
// test event with RDATE list
$e = kolabformat::readEvent($rdates, false);
$ec = new EventCal($e);
$rstart = new cDateTime(2012, 3, 1, 0, 0, 0);
$next = new cDateTime($ec->getNextOccurence($rstart));
assertequal(sprintf("%d-%02d-%02d %02d:%02d:%02d", $next->year(), $next->month(), $next->day(), $next->hour(), $next->minute(), $next->second()), "2012-03-30 04:00:00", "RDATE first recurrence");
$next = new cDateTime($ec->getNextOccurence($next));
assertequal(sprintf("%d-%02d-%02d %02d:%02d:%02d", $next->year(), $next->month(), $next->day(), $next->hour(), $next->minute(), $next->second()), "2013-03-30 04:00:00", "RDATE next recurrence");
$last = new cDateTime($ec->getLastOccurrence());
assertequal(sprintf("%d-%02d-%d %02d:%02d:%02d", $last->year(), $last->month(), $last->day(), $last->hour(), $last->minute(), $last->second()), "2021-03-30 04:00:00", "RDATE last occurence");
// terminate with error status
exit($errors);
コード例 #2
0
$att2 = new Attendee(new ContactReference("*****@*****.**"));
$att1->setPartStat(kolabformat::PartNeedsAction);
$vdelegatees = new vectorcontactref();
$vdelegatees->push($att2->contact());
$att1->setDelegatedTo($vdelegatees);
$vdelegators = new vectorcontactref();
$vdelegators->push($att1->contact());
$att2->setDelegatedFrom($vdelegators);
$attendees = new vectorattendee();
$attendees->push($att1);
$attendees->push($att2);
$e1->setAttendees($attendees);
$xml = kolabformat::writeEvent($e1);
assertcontains($xml, '<delegated-to><cal-address>mailto:%3Cjane%40kolab.org%3E</cal-address>', "Delegated-To");
assertcontains($xml, '<delegated-from><cal-address>mailto:%3Cjohn%40kolab.org%3E</cal-address>', "Delegated-From");
$e2 = kolabformat::readEvent($xml, false);
$attendees_ = $e2->attendees();
assertequal($attendees_->size(), 2, "Event::attendees()");
$att1_ = $attendees_->get(0);
$att2_ = $attendees_->get(1);
assertequal($att1_->contact()->email(), "*****@*****.**", "Attendee email");
$vdelegatees_ = $att1_->delegatedTo();
assertequal($vdelegatees_->size(), 1, "Attendee::delegatedTo()");
assertequal($vdelegatees_->get(0)->email(), "*****@*****.**", "Delegated-To email");
/////// Test Todo
$t = new Todo();
$t->setCreated(new cDateTime(2014, 3, 14, 9, 5, 30, true));
$due = new cDateTime(2014, 5, 20, 17, 30, 0);
$t->setDue($due);
$t->setStart(new cDateTime(2014, 4, 30, 8, 0, 0));
$t->setSummary('Test Task');