Пример #1
0
 /**
  * Set the time span from an array
  *
  * Any value can be a float (but it has no sense in seconds), for example:
  *
  *  <code>array(23.5, 20, 0)</code>
  *
  * is interpreted as 23 hours, .5*60 + 20 = 50 minutes and 0 seconds.
  *
  * @param array $time items are counted from right to left. First
  *                     item is for seconds, second for minutes, third
  *                     for hours and fourth for days. If there are
  *                     less items than 4, zero (0) is assumed for the
  *                     absent values.
  *
  * @return   bool       true on success
  * @access   public
  */
 function setFromArray($time)
 {
     if (!is_array($time)) {
         return false;
     }
     $tmp1 = new Date_Span();
     if (!$tmp1->setFromSeconds(@array_pop($time))) {
         return false;
     }
     $tmp2 = new Date_Span();
     if (!$tmp2->setFromMinutes(@array_pop($time))) {
         return false;
     }
     $tmp1->add($tmp2);
     if (!$tmp2->setFromHours(@array_pop($time))) {
         return false;
     }
     $tmp1->add($tmp2);
     if (!$tmp2->setFromDays(@array_pop($time))) {
         return false;
     }
     $tmp1->add($tmp2);
     return $this->copy($tmp1);
 }