Bug #80831 [Nab]: IntlDateFormatter considers January 2021 days to be January 2020 days
| From: | derick@php.net | Date: | Thu, 04 Mar 2021 16:21:11 +0000 |
| Subject: | Bug #80831 [Nab]: IntlDateFormatter considers January 2021 days to be January 2020 days | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-232561@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=80831&edit=1
ID: 80831
Updated by: derick@php.net
Reported by: sebastian@php.net
Summary: IntlDateFormatter considers January 2021 days to be
January 2020 days
Status: Not a bug
Type: Bug
Package: Date/time related
Operating System: Irrelevant
PHP Version: 8.0.3RC1
Block user comment: N
Private report: N
New Comment:
https://unicode-org.github.io/icu/userguide/format_parse/datetime/
Previous Comments:
------------------------------------------------------------------------
[2021-03-04 16:20:47] derick@php.net
Sorry, but your problem does not imply a bug in PHP itself. For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system
is not the
appropriate forum for asking support questions. Due to the volume
of reports we can not explain in detail here why your report is not
a bug. The support channels will be able to provide an explanation
for you.
Thank you for your interest in PHP.
There is a difference between a natural year and an ISO year, and I think "Y" is the ISO
year (belonging to full ISO weeks and days) in Intl speak, I think. You want just "y".
------------------------------------------------------------------------
[2021-03-04 16:12:27] sebastian@php.net
Description:
------------
I have DateTimeImmutable objects representing days/dates in January 2021. When I format these
objects using an IntlDateFormatter object with the "MMMM Y" formatting string then the
first three days of January 2021 are printed as January 2020.
Test script:
---------------
<?php declare(strict_types=1);
$formatter = new IntlDateFormatter(
'de_DE',
IntlDateFormatter::FULL,
IntlDateFormatter::FULL,
'Europe/Berlin',
IntlDateFormatter::GREGORIAN,
'MMMM Y'
);
var_dump($formatter->format(new DateTimeImmutable('2021-01-01')));
var_dump($formatter->format(new DateTimeImmutable('2021-01-02')));
var_dump($formatter->format(new DateTimeImmutable('2021-01-03')));
var_dump($formatter->format(new DateTimeImmutable('2021-01-04')));
Expected result:
----------------
string(11) "Januar 2021"
string(11) "Januar 2021"
string(11) "Januar 2021"
string(11) "Januar 2021"
Actual result:
--------------
string(11) "Januar 2020"
string(11) "Januar 2020"
string(11) "Januar 2020"
string(11) "Januar 2021"
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=80831&edit=1