public function add($duration)
    {
        $d1 = $this->refDate;
        $d2 = clone $d1;

        if ($duration instanceof QtiDuration) {
            $toAdd = $duration;
        } elseif ($duration instanceof DateInterval) {
            $toAdd = self::createFromDateInterval($duration);
        } else {
            return;
        }

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

        $interval = $d2->diff($d1);
        $this->interval = $interval;
    }
public function add($duration)
    {
        $d1 = $this->refDate;
        $d2 = clone $d1;

        if ($duration instanceof QtiDuration) {
            $toAdd = $duration;
        } elseif ($duration instanceof DateInterval) {
            $toAdd = self::createFromDateInterval($duration);
        } else {
            return;
        }

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

        $interval = $d2->diff($d1);
        $this->interval = $interval;
    }
public function add ( $ duration ) { $ d1 = $ this -> refDate ; $ d2 = clone $ d1 ; if ( $ duration instanceof QtiDuration ) { $ toAdd = $ duration ; } elseif ( $ duration instanceof DateInterval ) { $ toAdd = self :: createFromDateInterval ( $ duration ) ; } else { return ; } $ d2 -> add ( new DateInterval ( $ this -> __toString ( ) ) ) ; $ d2 -> add ( new DateInterval ( $ toAdd -> __toString ( ) ) ) ; $ interval = $ d2 -> diff ( $ d1 ) ; $ this -> interval = $ interval ; }
Add a duration to this one.

For instance, PT1S + PT1S = PT2S.

@param \qtism\common\datatypes\Duration|\DateInterval $duration A Duration or DateInterval object.
Add a duration to this one .