public function lessThan(cDateTime $b) { if ($this->kind != $b->kind) { $trace = debug_backtrace(); trigger_error('Incompatible cDateTime kinds in lessThan() in ' . $trace[0]['file'] . ' on line ' . $trace[0]['line'], E_USER_NOTICE); return null; } switch ($this->kind) { case self::DATE_KIND: return date_create($this->format('Y-m-d')) < date_create($b->format('Y-m-d')); case self::TIME_KIND: return date_create($this->format('H:i:s.u')) < date_create($b->format('H:i:s.u')); case self::DATETIMELOCAL_KIND: return date_create($this->format('Y-m-d\\TH:i:s.u')) < date_create($b->format('Y-m-d\\TH:i:s.u')); $this->format(''); case self::MONTH_KIND: return date_create($this->format('Y-m')) < date_create($b->format('Y-m')); case self::WEEK_KIND: return date_create($this->format('o-\\WW')) < date_create($b->format('o-\\WW')); case self::DATETIME_KIND: return date_create($this->format('Y-m-d\\TH:i:s.uP')) < date_create($b->format('Y-m-d\\TH:i:s.uP')); } $trace = debug_backtrace(); trigger_error('Unknown cDateTime kind in lessThan() in ' . $trace[0]['file'] . ' on line ' . $trace[0]['line'], E_USER_NOTICE); return null; }
</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);