Ejemplo n.º 1
0
 /**
  * Set the span from the elapsed time between two dates.
  *
  * Set the span from the elapsed time between two dates. The time span
  * is allways positive, so the date's order is not important.
  *
  * @param
  *        	object Date $date1 First Date.
  * @param
  *        	object Date $date2 Second Date.
  *        	
  * @return bool True on success.
  *        
  * @access public
  */
 function setFromDateDiff($date1, $date2)
 {
     if (!is_a($date1, 'date') or !is_a($date2, 'date')) {
         return false;
     }
     $date1->toUTC();
     $date2->toUTC();
     if ($date1->after($date2)) {
         list($date1, $date2) = array($date2, $date1);
     }
     $days = Calc::dateDiff($date1->getDay(), $date1->getMonth(), $date1->getYear(), $date2->getDay(), $date2->getMonth(), $date2->getYear());
     $hours = $date2->getHour() - $date1->getHour();
     $mins = $date2->getMinute() - $date1->getMinute();
     $secs = $date2->getSecond() - $date1->getSecond();
     $this->setFromSeconds($days * 86400 + $hours * 3600 + $mins * 60 + $secs);
     return true;
 }