Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/php-8.1-strftime.php
Original file line numberDiff line numberDiff line change
Expand Up@@ -95,7 +95,11 @@ function strftime (string $format, $timestamp = null, ?string $locale = null) :
// in formatted strings.
// To adjust for this, a custom calendar can be supplied with a cutover date arbitrarily far in the past.
$calendar = IntlGregorianCalendar::createInstance();
$calendar->setGregorianChange(PHP_INT_MIN);
// NOTE: IntlGregorianCalendar::createInstance DOES NOT return an IntlGregorianCalendar instance when
// using a non-Gregorian locale (e.g. fa_IR)! In that case, setGregorianChange will not exist.
if ($calendar instanceof IntlGregorianCalendar) {
$calendar->setGregorianChange(PHP_INT_MIN);
}

return (new IntlDateFormatter($locale, $date_type, $time_type, $tz, $calendar, $pattern))->format($timestamp);
};
Expand Down