function testGetDateTimeCached() { $tz = new DateTimeZone('Europe/Amsterdam'); $dt1 = new datetime('1985-07-04 01:30:00', $tz); $dt2 = new datetime('1986-07-04 01:30:00', $tz); $dt1->settimezone($tz); $dt2->settimezone($tz); $elem = new Sabre_VObject_Property_MultiDateTime('DTSTART'); $elem->setDateTimes(array($dt1, $dt2)); $this->assertEquals($elem->getDateTimes(), array($dt1, $dt2)); }
/** * @depends testValues */ function testComplexExclusions() { $ev = new Sabre_VObject_Component('VEVENT'); $ev->UID = 'bla'; $ev->RRULE = 'FREQ=YEARLY;COUNT=10'; $dtStart = new Sabre_VObject_Property_DateTime('DTSTART'); $tz = new DateTimeZone('Canada/Eastern'); $dtStart->setDateTime(new DateTime('2011-01-01 13:50:20', $tz), Sabre_VObject_Property_DateTime::LOCALTZ); $exDate1 = new Sabre_VObject_Property_MultiDateTime('EXDATE'); $exDate1->setDateTimes(array(new DateTime('2012-01-01 13:50:20', $tz), new DateTime('2014-01-01 13:50:20', $tz)), Sabre_VObject_Property_DateTime::LOCALTZ); $exDate2 = new Sabre_VObject_Property_MultiDateTime('EXDATE'); $exDate2->setDateTimes(array(new DateTime('2016-01-01 13:50:20', $tz)), Sabre_VObject_Property_DateTime::LOCALTZ); $ev->add($dtStart); $ev->add($exDate1); $ev->add($exDate2); $vcal = Sabre_VObject_Component::create('VCALENDAR'); $vcal->add($ev); $it = new Sabre_VObject_RecurrenceIterator($vcal, (string) $ev->uid); $this->assertEquals('yearly', $it->frequency); $this->assertEquals(1, $it->interval); $this->assertEquals(10, $it->count); $max = 20; $result = array(); foreach ($it as $k => $item) { $result[] = $item; $max--; if (!$max) { break; } } $this->assertEquals(array(new DateTime('2011-01-01 13:50:20', $tz), new DateTime('2013-01-01 13:50:20', $tz), new DateTime('2015-01-01 13:50:20', $tz), new DateTime('2017-01-01 13:50:20', $tz), new DateTime('2018-01-01 13:50:20', $tz), new DateTime('2019-01-01 13:50:20', $tz), new DateTime('2020-01-01 13:50:20', $tz)), $result); }