public function adjustedTo($reference_date): self
    {
        if (!$reference_date instanceof DateTimeImmutable) {
            $reference_date = Datepoint::create($reference_date);
        }

        $duration = self::create($reference_date->diff($reference_date->add($this)));
        if ($duration == $this) {
            return $this;
        }

        return $duration;
    }
public function adjustedTo($reference_date): self
    {
        if (!$reference_date instanceof DateTimeImmutable) {
            $reference_date = Datepoint::create($reference_date);
        }

        $duration = self::create($reference_date->diff($reference_date->add($this)));
        if ($duration == $this) {
            return $this;
        }

        return $duration;
    }
public function adjustedTo ( $ reference_date ) : self { if ( ! $ reference_date instanceof DateTimeImmutable ) { $ reference_date = Datepoint :: create ( $ reference_date ) ; } $ duration = self :: create ( $ reference_date -> diff ( $ reference_date -> add ( $ this ) ) ) ; if ( $ duration == $ this ) { return $ this ; } return $ duration ; }
Returns a new instance with recalculate properties according to a given datepoint.

This method MUST retain the state of the current instance, and return
an instance that contains the time and date segments recalculate to remove
carry over points.

@param mixed $reference_date a reference datepoint {@see \League\Period\Datepoint::create}
Returns a new instance with recalculate properties according to a given datepoint .