[php-src] Issue #10484: IntlDateFormater: recalculation of date gregorian>chinese(!)>gregorian fails
| From: | porthd | Date: | Thu, 02 Feb 2023 06:19:12 +0000 |
| Subject: | [php-src] Issue #10484: IntlDateFormater: recalculation of date gregorian>chinese(!)>gregorian fails | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-243615@lists.php.net to get a copy of this message | ||
Issue: https://github.com/php/php-src/issues/10484
Author: porthd
### Description
Other calendars like islamic, buddhist instead of chinese are working like expected. The following
code fails ([discussed in german language
here](https://www.php.de/forum/webentwicklung/php-fortgeschrittene/1607278-chinesisches-datum-westliches-datum-fehlerhaft-falsche-konfiguriert-oder-php-bug)
):
```php
<?php
$locale = 'de_DE@calendar=chinese';
$traditionalFormatter = new IntlDateFormatter(
$locale,
IntlDateFormatter::MEDIUM,
IntlDateFormatter::SHORT,
'Europe/Berlin',
IntlDateFormatter::TRADITIONAL
);
$gregorianFormatter = new IntlDateFormatter(
$locale,
IntlDateFormatter::MEDIUM,
IntlDateFormatter::SHORT,
'Europe/Berlin',
IntlDateFormatter::GREGORIAN
);
$dateTime = DateTime::createFromFormat('Y-m-d H:i:s', '2022-10-30 23:27:06');
$traditionalDate = $traditionalFormatter->format($dateTime);
$parsedTimestamp = $traditionalFormatter->parse($traditionalDate);
var_dump($gregorianFormatter->format($dateTime));
var_dump($gregorianFormatter->format($parsedTimestamp));
```
Resulted in this output:
```
string(18) "2022 Okt. 31 00:27"
string(17) "2599 Dez. 5 00:27"
```
But I expected this output instead:
```
string(18) "2022 Okt. 31 00:27"
string(17) "2022 Okt. 31 00:27"
```
### PHP Version
PHP 7.4.33, PHP 8.0.27, PHP 8.1.14, PHP 8.2.1
### Operating System
_No response_