[php-src] Issue #20255: Add a predefined calendar constant in IntlDateFormatter for the proleptic gregorian calendar

From: Date: Tue, 21 Oct 2025 17:14:58 +0000
Subject: [php-src] Issue #20255: Add a predefined calendar constant in IntlDateFormatter for the proleptic gregorian calendar
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-251097@lists.php.net to get a copy of this message
Issue: https://github.com/php/php-src/issues/20255 Author: stof ### Description Date arithmetic in timelib (and so in DateTimeImmutable) is based on the "proleptic gregorian" calendar (i.e. a calendar that does not have a cutover switching to the Julian calendar for dates before the cutover). On the other hand, IntlDateFormatter::GREGORIAN (the default calendar in IntlDateFormatter) is an hybrid calendar switching to Julian calendar for past dates. There is a way to use a proleptic Gregorian calendar by providing a calendar object explicitly: ```php $calendar = new \IntlGregorianCalendar(); $calendar->setGregorianChange(-INF); ``` However, this is a lot less convenient than using of the integer constants (the timezone passed to the formatter is ignored, having to set it in the calendar object instead, for instance). The mismatch between the behavior of DateTimeImmutable and IntlDateFormatter leads to surprising issues (which happen only when using dates far in the past, making them easy to miss). See https://github.com/symfony/symfony/issues/31057 for an issue opened in Symfony which is caused by that mismatch. It would be great to expose a predefined constant allowing to easily use the proleptic gregorian calendar in IntlDateFormatter (maybe even making it the default in the future, but that may be tricky to provide a migration path).

« previous php.bugs (#251097) next »