alphp / strftime

This provides a cross-platform alternative to strftime() for when it will be removed from PHP

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

PHP fatal error "Call to undefined method IntlCalendar::setGregorianChange()" with non-Gregorian locales

asmecher opened this issue · comments

Try the following test script. (You may have to generate the fa_IR locale on your system first.)

<?php

setlocale(LC_ALL, 'fa_IR') || die("Could not set locale!\n");
require_once('autoload.php');

echo PHP81_BC\strftime('%b', time());

You will get a fatal error message:

PHP Fatal error:  Uncaught Error: Call to undefined method IntlCalendar::setGregorianChange() in /path/to/test.php:5
Stack trace:
#0 {main}
  thrown in /path/to/test.php on line 5

This is because IntlGregorianCalendar::createInstance() will not return an IntlGregorianCalendar when the locale is set to something non-Gregorian. (Note that the error message says it's an IntlCalendar.)

Pull request: #16

(Source: https://forum.pkp.sfu.ca/t/submission-files-is-not-showing-in-ojs-3-3-0-11/83976/10)