Skip to content

Commit

Permalink
Returns SMF\TimeInterval objects from SMF\Time::diff()
Browse files Browse the repository at this point in the history
Signed-off-by: Jon Stovell <[email protected]>
  • Loading branch information
Sesquipedalian committed Dec 26, 2024
1 parent 4be2295 commit 2841c29
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions Sources/Time.php
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,18 @@ public function __isset(string $prop): bool
}
}

/**
* Like \DateTime::diff(), but returns a TimeInterval object.
*
* @param \DateTimeInterface $target The date to compare to.
* @param bool $absolute Whether to force the interval to be positive.
* @return TimeInterval The difference between the two dates.
*/
public function diff(\DateTimeInterface $target, bool $absolute = false): TimeInterval
{
return TimeInterval::createFromDateInterval(parent::diff($target, $absolute));
}

/**
* Like DateTime::format(), except that it can accept either DateTime format
* specifiers or strftime format specifiers (but not both at once).
Expand Down

0 comments on commit 2841c29

Please sign in to comment.