Esempio n. 1
0
 public function testGetWeekStart()
 {
     $this->assertEquals('2014-01-26', Week::getWeekStart(new \DateTime('2014-01-26'))->format('Y-m-d'));
     $this->assertEquals('2014-01-26', Week::getWeekStart(new \DateTime('2014-01-29'))->format('Y-m-d'));
     $this->assertEquals('2014-01-26', Week::getWeekStart(new \DateTime('2014-02-01'))->format('Y-m-d'));
     $this->assertEquals('2014-02-02', Week::getWeekStart(new \DateTime('2014-02-02'))->format('Y-m-d'));
 }
Esempio n. 2
0
 /**
  * Add an event to the DiaryView. Works out the week(s) to which the event should be added. Multi-day events
  * may need to be added to multiple weeks if they cross a week boundary.
  *
  * @param EventInterface $event
  */
 public function addEvent(EventInterface $event)
 {
     if ($event instanceof MultiDayEventInterface) {
         //If it's a multi-day event, we may well need to display it in multiple weeks
         $week_start = Week::getWeekStart($event->getStartDate());
         do {
             $week = $this->getWeekForDate($week_start);
             if ($week) {
                 $week->addEvent($event);
             }
             $week_start->modify('+7 days');
         } while ($week_start < $event->getEndDate());
     } elseif ($event instanceof SingleDayEventInterface) {
         $this->getWeekForDate($event->getDate())->addEvent($event);
         //If its end time is before its start time, we assume this means it continues until that time the next day
         if ($event->getEndTime() < $event->getStartTime() && $event->getDate()->format('N') == 6) {
             $tomorrow = $event->getDate()->modify('+1 day');
             $week = $this->getWeekForDate($tomorrow);
             if ($week) {
                 $week->addEvent($event);
             }
         }
     }
 }