ageByYear() 공개 정적인 메소드

Returns the age only with the year available can be e.g. 22/23
public static ageByYear ( integer $year, integer | null $month = null ) : integer | string
$year integer
$month integer | null (optional)
리턴 integer | string Age
예제 #1
0
 /**
  * TimeTest::testAgeByYear()
  *
  * @return void
  */
 public function testAgeByYear()
 {
     //$this->out($this->_header(__FUNCTION__), true);
     // year only
     $is = $this->Time->ageByYear(2000);
     //$this->out($is);
     $this->assertEquals(date('Y') - 2001 . '/' . (date('Y') - 2000), $is);
     $is = $this->Time->ageByYear(1985);
     $this->assertEquals(date('Y') - 1986 . '/' . (date('Y') - 1985), $is);
     // with month
     if (($month = date('n') + 1) <= 12) {
         $is = $this->Time->ageByYear(2000, $month);
         //$this->out($is);
         //$this->assertEquals($is, (date('Y')-2001).'/'.(date('Y')-2000), null, '2000/'.$month);
         $this->assertSame(date('Y') - 2001, $is);
         //null, '2000/'.$month
     }
     if (($month = date('n') - 1) >= 1) {
         $is = $this->Time->ageByYear(2000, $month);
         //$this->out($is);
         //$this->assertEquals($is, (date('Y')-2001).'/'.(date('Y')-2000), null, '2000/'.$month);
         $this->assertSame(date('Y') - 2000, $is);
         //null, '2000/'.$month)
     }
 }