Beispiel #1
0
 /**
  * Returns the matching days for a given month
  * @param $month
  * @return int
  */
 public function getDaysInMonth($month)
 {
     if ($this->start->getYear() < $this->end->getYear()) {
         return cal_days_in_month(CAL_GREGORIAN, $month, $this->start->getYear());
     }
     $localStart = null;
     $localEnd = null;
     if ($this->start->getMonth() == $month) {
         $localStart = $this->start;
     }
     if ($this->end->getMonth() == $month) {
         $localEnd = $this->end;
     }
     if ($localStart == null) {
         $localStart = SimpleDateTime::createFromFormat("Y-m-d", $this->start->getYear() . "-{$month}-01");
     }
     if ($localEnd == null) {
         $localEnd = SimpleDateTime::createFromFormat("Y-m-d", $this->start->getYear() . "-" . ($month + 1) . "-01");
     }
     $diff = new TimeSpan($localStart, $localEnd);
     return $diff->getDaysBetween();
 }