Skip to content

Commit 7a01ea4

Browse files
committed
Fix error reported by phpstan in I18n/RelativeTimeFormatter.
1 parent 360319a commit 7a01ea4

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/I18n/RelativeTimeFormatter.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public function diffForHumans(ChronosInterface $date, ChronosInterface $other =
3737
{
3838
$isNow = $other === null;
3939
if ($isNow) {
40-
$other = $date->now($date->tz);
40+
$other = $date->now($date->getTimezone());
4141
}
4242
$diffInterval = $date->diff($other);
4343

@@ -94,7 +94,7 @@ public function diffForHumans(ChronosInterface $date, ChronosInterface $other =
9494
public function timeAgoInWords(DatetimeInterface $time, array $options = [])
9595
{
9696
$options = $this->_options($options, FrozenTime::class);
97-
if ($options['timezone']) {
97+
if ($options['timezone'] && $time instanceof ChronosInterface) {
9898
$time = $time->timezone($options['timezone']);
9999
}
100100

@@ -284,7 +284,7 @@ protected function _diffData($futureTime, $pastTime, $backwards, $options)
284284
public function dateAgoInWords(DatetimeInterface $date, array $options = [])
285285
{
286286
$options = $this->_options($options, FrozenDate::class);
287-
if ($options['timezone']) {
287+
if ($options['timezone'] && $date instanceof ChronosInterface) {
288288
$date = $date->timezone($options['timezone']);
289289
}
290290

0 commit comments

Comments
 (0)