Compares this Duration to the specified duration.

@param \Brick\DateTime\Duration $that The other duration to compare to.

@return int [-1,0,1] If this duration is less than, equal to, or greater than the given duration.
768491
public function compareTo(Duration $that) : int
    {
        $seconds = $this->seconds - $that->seconds;

        if ($seconds !== 0) {
            return $seconds > 0 ? 1 : -1;
        }

        $nanos = $this->nanos - $that->nanos;

        if ($nanos !== 0) {
            return $nanos > 0 ? 1 : -1;
        }

        return 0;
    }
588467
public function get_duration($convert = false)
	{
		if ($this->duration !== null)
		{
			if ($convert)
			{
				$time = SimplePie_Misc::time_hms($this->duration);
				return $time;
			}
			else
			{
				return $this->duration;
			}
		}
		else
		{
			return null;
		}
	}
965795
@Override
  public int compareTo(V1Annotation that) {
    if (this == that) return 0;
    int byTimestamp = timestamp < that.timestamp ? -1 : timestamp == that.timestamp ? 0 : 1;
    if (byTimestamp != 0) return byTimestamp;
    return value.compareTo(that.value);
  }
152875
public function equals(self $that): bool
    {
        if (get_class($this) !== get_class($that)) {
            throw new CannotCompareDifferentIds;
        }
        return $this->id === $that->id;
    }
350988
function duration2date($startdate=FALSE, $duration=FALSE) {
    if( $startdate && $duration ) {
      $d1               = $startdate;
      $dur              = $duration;
    }
    elseif( isset( $this->dtstart['value'] ) && isset( $this->duration['value'] )) {
      $d1               = $this->dtstart['value'];
      $dur              = $this->duration['value'];
    }
    else
      return null;
    $dateOnly         = ( isset( $d1['hour'] ) || isset( $d1['min'] ) || isset( $d1['sec'] )) ? FALSE : TRUE;
    $d1['hour']       = ( isset( $d1['hour'] )) ? $d1['hour'] : 0;
    $d1['min']        = ( isset( $d1['min'] ))  ? $d1['min']  : 0;
    $d1['sec']        = ( isset( $d1['sec'] ))  ? $d1['sec']  : 0;
    $dtend = mktime( $d1['hour']
                    , $d1['min']
                    , $d1['sec']
                    , $d1['month']
                    , $d1['day']
                    , $d1['year'] );
    if( isset( $dur['week'] ))
      $dtend += ( $dur['week'] * 7 * 24 * 60 * 60 );
    if( isset( $dur['day'] ))
      $dtend += ( $dur['day'] * 24 * 60 * 60 );
    if( isset( $dur['hour'] ))
      $dtend += ( $dur['hour'] * 60 *60 );
    if( isset( $dur['min'] ))
      $dtend += ( $dur['min'] * 60 );
    if( isset( $dur['sec'] ))
      $dtend +=   $dur['sec'];
    $dtend2 = array();
    $dtend2['year']   = date('Y', $dtend );
    $dtend2['month']  = date('m', $dtend );
    $dtend2['day']    = date('d', $dtend );
    $dtend2['hour']   = date('H', $dtend );
    $dtend2['min']    = date('i', $dtend );
    $dtend2['sec']    = date('s', $dtend );
    if( isset( $d1['tz'] ))
      $dtend2['tz']   = $d1['tz'];
    if( $dateOnly && (( 0 == $dtend2['hour'] ) && ( 0 == $dtend2['min'] ) && ( 0 == $dtend2['sec'] )))
      unset( $dtend2['hour'], $dtend2['min'], $dtend2['sec'] );
    return $dtend2;
  }
65295
public static function FromDuration( $duration )
	{
		if ( $duration instanceof DurationValue )
			$duration = $duration->getValue();

		// Correct the month count
		if ( $duration->d > 30 && $duration->m > 0 ) $duration->m -= 1;

		$duration->d = 0;
		$duration->h = 0;
		$duration->i = 0;
		$duration->s = 0;
		$duration->microseconds = 0;
		$duration->daysOnly = false;

		return new YearMonthDurationValue( $duration );
	}
350919
function CompareTo( $obj )
	{
		if ( ! $obj instanceof TimeValue )
			throw new ArgumentException("$obj");

		/**
		 * @var TimeValue $other
		 */
		$other = $obj;
		return $this->Value == $other->Value
			? 0
			: ( $this->Value > $other->Value ? 1 : -1 );
	}
880883
public function Equals( $obj )
	{
		if ( ! $obj instanceof DurationValue )
		{
			return false;
		}

		/**
		 * @var DurationValue $other
		 */
	    $other = $obj;

		if ( $other->getIsZero() && $this->getIsZero())
			return true;

		if ( $this->getType() != $other->getType() ) return false;

		return $this->ToString() == $other->ToString();
	}
1268586
function icaltime_compare(other) {
      var a = this.toUnixTime();
      var b = other.toUnixTime();

      if (a > b) return 1;
      if (b > a) return -1;
      return 0;
    }
434044
public static function duration ($duration)
		{
			if (is_numeric($duration))
			{
				$negative = ( $duration < 0 );
				if ($negative)
					$duration = -$duration;

				if (strpos($duration, '.') === false)
					list($seconds, $tail) = [ $duration, 0 ];
				else
					list($seconds, $tail) = explode('.', $duration);

				$dt = new \DateTime('@0');
				$dt2 = new \DateTime("@" . $seconds);

				return ( $negative ? '-' : '' ) . $dt->diff($dt2)->format('%H:%I:%S') . '.' . str_pad($tail, 3, '0', STR_PAD_RIGHT);
			}

			return null;
		}
458117
public function sub(QtiDuration $duration)
    {
        if ($duration->longerThanOrEquals($this) === true) {
            $this->setInterval(new DateInterval('PT0S'));
        } else {
            $refStrDate = '@0';
            $tz = new DateTimeZone(self::TIMEZONE);
            $d1 = new DateTime($refStrDate, $tz);
            $d2 = new DateTime($refStrDate, $tz);

            $d1->add(new DateInterval($this->__toString()));
            $d2->add(new DateInterval($duration->__toString()));

            $interval = $d1->diff($d2);
            $this->setInterval($interval);
        }
    }
44124
private function duration($time){
        if(is_numeric($time)){ 
            return $time;
        }//if
        return (new \DateTime($time))->getTimestamp() - (new \DateTime('now'))->getTimestamp();
    }
1235623
public function setDuration($duration)
    {
        // get dom element
        $durationDomElement = $this->getDomElement()->getElementsByTagName('Duration')->item(0);
        if (!$durationDomElement) {
            $durationDomElement = $this->getDomElement()->ownerDocument->createElement('Duration');
            $this->getDomElement()->firstChild->appendChild($durationDomElement);
        }

        // set value
        if (is_numeric($duration)) {
            // in seconds
            $duration = $this->secondsToString($duration);
        }

        $durationDomElement->nodeValue = $duration;

        return $this;
    }
554575
public function Sub( $duration )
	{
		if ( ! $duration instanceof DurationValue )
		{
			throw new \InvalidArgumentException();
		}

		$duration->Value->invert = ! $duration->Value->invert;
		$this->Add( $duration );

		// // Finally convert $multipliedInterval into a normalized interval
		// /**
		//  * @var \DateTime $dt
		//  */
		// $dt = new \DateTimeImmutable( "2017-06-07" );
		// /**
		//  * @var \DateTime $added
		//  */
		// $added = $dt->add( $this->Value );
		// $duration->Value->invert = ! $duration->Value->invert;
		// /**
		//  * @var \DateTime $subtracted
		//  */
		// $subtracted = $added->add( $duration->Value );
		// /**
		//  * @var \DateInterval $diff
		//  */
		// $diff = $subtracted->diff( $dt );
		// $diff->invert = $diff->days == 0 ? false : ! $diff->invert;
        //
		// $this->Value = $diff;
	}
264336
private function get_time_duration_from_form_data(\stdClass $data) {
        if ($data->duration == 1) {
            return $data->timedurationuntil - $data->timestart;
        } else if ($data->duration == 2) {
            return $data->timedurationminutes * MINSECS;
        } else {
            return 0;
        }
    }
994210
public function timer_diff()
    {
        $PAGELOADTIME = microtime();
        $PAGELOADTIME = explode(' ', $PAGELOADTIME);
        $PAGELOADTIME = $PAGELOADTIME[1] + $PAGELOADTIME[0];
        $now = $PAGELOADTIME;
        $TIMEDIFF = ($now - $this->basetime);

        return $TIMEDIFF;
    }
663866
public static function timeDifferent($time1, $time2)
    {
        $intTime1 = $this->unixTime($time1);
        $intTime2 = $this->unixTime($time2);
        $timeDiff = $intTime2 - $intTime1;

        return $timeDiff;
    }