Skip to content

Commit 69ca341

Browse files
Returns SMF\TimeInterval objects from SMF\Time::diff()
Signed-off-by: Jon Stovell <[email protected]>
1 parent 3a8c7cd commit 69ca341

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

Sources/Time.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -439,6 +439,18 @@ public function __isset(string $prop): bool
439439
}
440440
}
441441

442+
/**
443+
* Like \DateTime::diff(), but returns a TimeInterval object.
444+
*
445+
* @param \DateTimeInterface $target The date to compare to.
446+
* @param bool $absolute Whether to force the interval to be positive.
447+
* @return TimeInterval The difference between the two dates.
448+
*/
449+
public function diff(\DateTimeInterface $target, bool $absolute = false): TimeInterval
450+
{
451+
return TimeInterval::createFromDateInterval(parent::diff($target, $absolute));
452+
}
453+
442454
/**
443455
* Like DateTime::format(), except that it can accept either DateTime format
444456
* specifiers or strftime format specifiers (but not both at once).

0 commit comments

Comments
 (0)