Example #1
0
 /**
  * Returns the month objects to display
  *
  * @return  Month[]
  */
 public function build()
 {
     if (!isset($this->currentDate)) {
         return array();
     }
     // We need to know how many months to display, so that's the first job:
     $monthsToDisplay = array();
     $thisMonth = new Month($this->currentDate);
     // Go backwards first:
     for ($i = $this->monthOverflow['left']; $i != 0; $i--) {
         $monthsToDisplay[] = $thisMonth->prev($i);
     }
     // And the current:
     $monthsToDisplay[] = $thisMonth;
     // And then forwards:
     for ($i = 1; $i <= $this->monthOverflow['right']; $i++) {
         $monthsToDisplay[] = $thisMonth->next($i);
     }
     return $monthsToDisplay;
 }
Example #2
0
 public function testTimeframeImplementation()
 {
     $m = new Month(new DateTime('2014-04-16'));
     $this->assertEquals('2014-04-01 00:00:00', $m->start()->format('Y-m-d H:i:s'));
     $this->assertEquals('2014-04-30 23:59:59', $m->end()->format('Y-m-d H:i:s'));
 }