public function testGetDaysOverflowsRear() { $w = new Week(new DateTime('2014-07-02')); $w->setContainingMonth(new Month(new DateTime('2014-06-30'))); $days = $w->days(); $this->assertFalse($days[0]->isOverflow()); $this->assertTrue($days[1]->isOverflow()); $this->assertTrue($days[2]->isOverflow()); $this->assertTrue($days[3]->isOverflow()); $this->assertTrue($days[4]->isOverflow()); $this->assertTrue($days[5]->isOverflow()); $this->assertTrue($days[6]->isOverflow()); }
/** * Returns the weeks associated with this month. Not all of these weeks might * start and end in this month, but they all contain days from this month. * * @param string $startDay The day that weeks start on. * @return Week[] */ public function weeks($startDay = 'Monday') { if (!isset($this->weeks[$startDay])) { $this->weeks[$startDay] = array(); $keepWeeking = true; $weekPoint = clone $this->firstDay(); while ($keepWeeking) { $candidateWeek = new Week($weekPoint, $startDay); if ($candidateWeek->weekStart() <= $this->lastDay()) { $candidateWeek->setContainingMonth($this); $this->weeks[$startDay][] = $candidateWeek; $weekPoint->modify('+1 week'); } else { $keepWeeking = false; } } } return $this->weeks[$startDay]; }