[php-src] Issue #14500: IntlDateFormatter::format() displays weekday and week number incorrectly.
| From: | Wiimm | Date: | Fri, 07 Jun 2024 19:30:47 +0000 |
| Subject: | [php-src] Issue #14500: IntlDateFormatter::format() displays weekday and week number incorrectly. | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-247060@lists.php.net to get a copy of this message | ||
Issue: https://github.com/php/php-src/issues/14500
Author: Wiimm
### Description
Class IntlDateFormatter displays weekday and week number incorrectly. The example date is
2021-01-02, which belongs to the last week of 2020. In addition, the number of the day of the week
is displayed incorrectly.
```#!/usr/bin/env php
<?PHP
# tested with PHP 7.2.5 + 7.4.6 + 8.3.6 + 8.3.7
# output always:
#> SFT: 2021-01-02 12:00:00 / wday: 6=Sat / week: 2020-53
#> IDF: 2021-01-02 12:00:00 / wday: 7=Sat / week: 2021-01
# ERROR: ^ ^^^^ ^^
$locale = 'en_US.UTF-8';
$timezone = 'UTC';
$time = strtotime('2021-01-02 12:00');
setlocale(LC_TIME,$locale);
date_default_timezone_set($timezone);
echo strftime('SFT: %F %T / wday: %u=%a / week: %G-%V%n',$time);
$idf = new IntlDateFormatter(
$locale,
\IntlDateFormatter::FULL,
\IntlDateFormatter::FULL,
$timezone,
\IntlDateFormatter::GREGORIAN,
"yyyy-MM-dd HH:mm:ss '/ wday:' e=E '/ week:' Y-ww\n" );
echo 'IDF: ',$idf->format($time);
?>
```
Resulted in this output:
```
SFT: 2021-01-02 12:00:00 / wday: 6=Sat / week: 2020-53
IDF: 2021-01-02 12:00:00 / wday: 7=Sat / week: 2021-01
^ ^^^^ ^^
```
But I expected this output instead:
```
SFT: 2021-01-02 12:00:00 / wday: 6=Sat / week: 2020-53
IDF: 2021-01-02 12:00:00 / wday: 6=Sat / week: 2020-53
^ ^^^^ ^^
```
### PHP Version
PHP 7.2.5 .. 8.3.7
### Operating System
openSUSE Leap + Tumbleweed, Debian 11