Exemplo n.º 1
0
 function testMultiplication()
 {
     $dur = new jDuration(array("year" => 1));
     $dur->mult(10);
     // Changed our mind, 10 years is better...
     $dt = new jDateTime(2007, 1, 1, 23, 58, 3);
     $dtExpected = new jDateTime(1997, 1, 1, 23, 58, 3);
     $dt->sub($dur);
     $this->assertEqual($dt, $dtExpected);
 }
Exemplo n.º 2
0
 /**
  * substract a <b>duration</b> to the date
  * You can specify the duration in a jDuration object or give each value of
  * the duration.
  * @param jDuration/int $year the duration value or a year with 4 digits
  * @param int $month month with 2 digits
  * @param int $day day with 2 digits
  * @param int $hour hour with 2 digits
  * @param int $minute minute with 2 digits
  * @param int $second second with 2 digits
  */
 public function sub($year, $month = 0, $day = 0, $hour = 0, $minute = 0, $second = 0)
 {
     if ($year instanceof jDuration) {
         $dt = $year;
     } else {
         $dt = new jDuration(array("year" => $year, "month" => $month, "day" => $day, "hour" => $hour, "minute" => $minute, "second" => $second));
     }
     $dt->mult(-1);
     $this->add($dt);
 }