Skip to content

Commit fec4684

Browse files
committed
PHP 8.0 > mktime update
8.0.0 hour is no longer optional. 8.0.0 minute, second, month, day and year are nullable now.
1 parent 23725cb commit fec4684

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

lib/i18n/sfI18N.class.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,15 @@ public function getTimestampForCulture($dateTime, $culture = null)
271271
list($day, $month, $year) = $this->getDateForCulture($dateTime, null === $culture ? $this->culture : $culture);
272272
list($hour, $minute) = $this->getTimeForCulture($dateTime, null === $culture ? $this->culture : $culture);
273273

274+
// mktime behavior change with php8
275+
// $hour become not nullable
276+
if (!$hour) {
277+
$hour = 0;
278+
}
279+
// Before 8.0, $minutes value to null, was casted as (int)0
280+
if (!$minute) {
281+
$minute = 0;
282+
}
274283
return null === $day ? null : mktime($hour, $minute, 0, $month, $day, $year);
275284
}
276285

0 commit comments

Comments
 (0)