Exemplo n.º 1
0
function addBirthday($bday, $bmonth, $byear, $prefix)
{
    // Add the birthday
    if ($bday != 0 || $bmonth != "-" || $byear != "") {
        $month = ucfmsg(strtoupper($bmonth));
        $result = ($bday > 0 ? $bday . ". " : "") . ($month != '-' ? $month : "") . ($byear != "" ? " " . $byear : "");
        // Add the age
        $birthday = new Birthday($bday, $bmonth, $byear);
        $result .= $birthday->getAge() != -1 ? " (" . $birthday->getAge() . ")" : "";
        return add($result, $prefix);
    } else {
        return "";
    }
}
Exemplo n.º 2
0
 function testGetAge()
 {
     $birthday = new Birthday("5", "July", "2007");
     $birthday->today = mktime(0, 0, 0, 1, 29, 2011);
     $this->assertEqual($birthday->getAge(), 3);
     $birthday->today = mktime(0, 0, 0, 7, 4, 2011);
     $this->assertEqual($birthday->getAge(), 3);
     $birthday->today = mktime(0, 0, 0, 7, 5, 2011);
     $this->assertEqual($birthday->getAge(), 4);
     $birthday->today = mktime(0, 0, 0, 7, 6, 2011);
     $this->assertEqual($birthday->getAge(), 4);
     $birthday->today = mktime(0, 0, 0, 8, 28, 2011);
     $this->assertEqual($birthday->getAge(), 4);
     $birthday->today = mktime(0, 0, 0, 1, 1, 2012);
     $this->assertEqual($birthday->getAge(), 4);
     //
     // Without year = -1
     //
     $birthday = new Birthday("1", "July", "");
     $this->assertTrue($birthday->getAge() == -1);
 }