public function testTimeframeImplementation() { $w = new Week(new DateTime('2014-04-16')); $this->assertEquals('2014-04-14 00:00:00', $w->start()->format('Y-m-d H:i:s')); $this->assertEquals('2014-04-20 23:59:59', $w->end()->format('Y-m-d H:i:s')); }
/** * 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]; }