Example #1
0
 public function testAddTo()
 {
     $start = DateTime::create('21.11.1984 13:00');
     $iv = DateInterval::create('1 DAY');
     $this->assertEquals('22.11.1984 13:00', $iv->addTo($start)->format('d.m.Y H:i'));
     $this->assertEquals('21.11.1984 13:00', $start->format('d.m.Y H:i'));
 }
Example #2
0
 public function testYesterday()
 {
     $now = time();
     $yesterday = $now - 24 * 60 * 60;
     $beforeYesterday = $now - 48 * 60 * 60;
     $now = DateTime::factory($now);
     $yesterday = DateTime::factory($yesterday);
     $beforeYesterday = DateTime::factory($beforeYesterday);
     $this->assertTrue($yesterday->isYesterday());
     $this->assertTrue($yesterday->isYesterday($now));
     $this->assertFalse($beforeYesterday->isYesterday());
     $this->assertFalse($beforeYesterday->isYesterday($now));
     $now->add(DateInterval::createFromDateString('1 DAY'));
     $this->assertFalse($yesterday->isYesterday($now));
 }
Example #3
0
 public function ical()
 {
     $ical = $this->contentLine('BEGIN', 'VEVENT');
     if ($this->allDay) {
         $ical .= $this->contentLine('DTSTART', $this->icalDate($this->date), array('VALUE' => 'DATE'));
         $ical .= $this->contentLine('DTEND', $this->icalDate(DateInterval::create('1 DAY')->addTo($this->date)), array('VALUE' => 'DATE'));
     }
     $ical .= $this->icalRecurrence($this->recurrence);
     $ical .= $this->contentLine('DTSTAMP', $this->icalDateTime($this->stamp));
     $ical .= $this->contentLine('UID', $this->getUID());
     $ical .= $this->contentLine('CREATED', $this->icalDateTime($this->created));
     $ical .= $this->contentLine('DESCRIPTION', $this->description);
     $ical .= $this->contentLine('LAST-MODIFIED', $this->icalDateTime($this->modified));
     $ical .= $this->contentLine('LOCATION', $this->location);
     $ical .= $this->contentLine('SEQUENCE', $this->sequence);
     $ical .= $this->contentLine('STATUS', $this->status);
     $ical .= $this->contentLine('SUMMARY', $this->title);
     $ical .= $this->contentLine('TRANSP', 'TRANSPARENT');
     $ical .= $this->contentLine('END', 'VEVENT');
     return $ical;
 }
Example #4
0
 public function testIcalRecurrence()
 {
     $this->assertEquals($this->base->contentLine('RRULE', 'FREQ=YEARLY'), $this->base->icalRecurrence(DateInterval::create('1 YEAR')));
 }