Esempio n. 1
0
 /**
  * @depends testGetMonth
  */
 public function testSubMonth()
 {
     $month = new Month(new \DateTime('1987-06-18'));
     $month->subMonth();
     $this->assertEquals(5, $month->getMonth());
     $month->subMonth(0);
     $this->assertEquals(5, $month->getMonth());
     $month->subMonth(2);
     $this->assertEquals(3, $month->getMonth());
 }
Esempio n. 2
0
 /**
  * Get the distance between this and the given month.
  *
  * @param Month $month
  *
  * @return int Number of months
  */
 public function getDistance(Month $month)
 {
     $yd = $this->getYear() - $month->getYear();
     $md = $this->getMonth() - $month->getMonth();
     return ($yd * 12 + $md) * -1;
 }