public function Months()
 {
     if ($this->end === null) {
         return -1;
     }
     if ($this->end->Before($this->start)) {
         return -1;
     }
     if ($this->start->Month() == $this->end->Month() && $this->start->Year() == $this->end->Year()) {
         $wholeMonth = new Datumsbereich($this->start->FirstOfMonth(), $this->start->LastOfMonth());
         return $this->Length() / $wholeMonth->Length();
     }
     $startMonth = new Datumsbereich($this->start, $this->start->LastOfMonth());
     $wholeMonth = new Datumsbereich($this->start->FirstOfMonth(), $this->start->LastOfMonth());
     $total = $startMonth->Length() / $wholeMonth->Length();
     $between = new Datumsbereich($this->start->NextFirst(), $this->end->PreviousLast());
     $total += round($between->Length() / 30);
     $endMonth = new Datumsbereich($this->end->FirstOfMonth(), $this->end);
     $wholeMonth = new Datumsbereich($this->end->FirstOfMonth(), $this->end->LastOfMonth());
     $total += $endMonth->Length() / $wholeMonth->Length();
     if ($this->start->Day() == $this->end->Day() || $this->end->month() == 2 && $this->end->day() == $this->end->lastOfMonth()->day() && $this->end->day() < $this->start->day()) {
         $total = (int) round($total);
     }
     return $total;
 }
 public function testMonate()
 {
     $bereich = new Datumsbereich(new Datum('2008-10-16'), new Datum('2008-12-15'));
     $monate = $bereich->Monate();
     $this->assertEquals(3, count($monate));
     $first = reset($monate);
     $this->assertEquals(new Datumsbereich(new Datum('2008-10-16'), new Datum('2008-10-31')), $first);
     $next = next($monate);
     $this->assertEquals(new Datumsbereich(new Datum('2008-11-01'), new Datum('2008-11-30')), $next);
     $next = next($monate);
     $this->assertEquals(new Datumsbereich(new Datum('2008-12-01'), new Datum('2008-12-15')), $next);
 }