Skip to content

Commit 88c5c42

Browse files
committed
Allow passing DateTimeImmutables into format_interval.
1 parent 2ca28f5 commit 88c5c42

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

include/branches.inc

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,11 @@ function get_old_releases(): array
2626
return $cache ??= require __DIR__ . '/releases.inc';
2727
}
2828

29-
function format_interval($from, DateTime $to) {
29+
function format_interval($from, DateTime|DateTimeImmutable $to) {
3030
try {
31+
$from = ($from instanceof DateTimeImmutable) ? DateTime::createFromImmutable($from): $from;
32+
$to = ($to instanceof DateTimeImmutable) ? DateTime::createFromImmutable($to) : $to;
33+
3134
$from_obj = $from instanceof DateTime ? $from : new DateTime($from);
3235
$diff = $to->diff($from_obj);
3336

0 commit comments

Comments
 (0)