Beispiel #1
0
 /**
  * Returns (and creates if necessary) the week in which a certain \DateTime belongs
  *
  * @param \DateTime $date
  *
  * @return Week
  */
 private function getWeekForDate(\DateTime $date)
 {
     if ($this->start_date && $this->end_date) {
         if ($date < $this->start_date || $date >= $this->end_date) {
             return;
         }
     }
     foreach ($this->weeks as $week) {
         if ($week->contains($date)) {
             return $week;
         }
     }
     $week = new Week($date);
     $this->weeks[$week->getStartAt()->format('U')] = $week;
     return $week;
 }