コード例 #1
0
ファイル: Duration.php プロジェクト: celest-time/prototype
 /**
  * Returns a copy of this duration with the specified duration subtracted.
  * <p>
  * This instance is immutable and unaffected by this method call.
  *
  * @param duration Duration the duration to subtract, positive or negative, not null
  * @return Duration a {@code Duration} based on this duration with the specified duration subtracted, not null
  * @throws ArithmeticException if numeric overflow occurs
  */
 public function minusAmount(Duration $duration)
 {
     $secsToSubtract = $duration->getSeconds();
     $nanosToSubtract = $duration->getNano();
     if ($secsToSubtract == Long::MIN_VALUE) {
         return $this->_plus(Long::MAX_VALUE, -$nanosToSubtract)->_plus(1, 0);
     }
     return $this->_plus(-$secsToSubtract, -$nanosToSubtract);
 }