`IntlDateFormatter` returns wrong output for 1940 date in Amsterdam timezone
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- C
- Sterne
- 40.4k
- Forks
- 8.1k
- Ø Merge
- 2 T. 13 Std.
- Gemergte PRs (30 T.)
- 96
Beschreibung
Description
The following code:
<?php
$timezone = new DateTimeZone("Europe/Amsterdam");
$date = new DateTime("1940-01-01 00:00:00", $timezone);
var_dump($date);
$formatter = new IntlDateFormatter("en-US");
var_dump($formatter->format($date));
Resulted in this output:
object(DateTime)#2 (3) {
["date"]=>
string(26) "1940-01-01 00:00:00.000000"
["timezone_type"]=>
int(3)
["timezone"]=>
string(16) "Europe/Amsterdam"
}
string(69) "Sunday, December 31, 1939 at 11:40:00 PM Coordinated Universal Time"
But I expected this output instead:
object(DateTime)#2 (3) {
["date"]=>
string(26) "1940-01-01 00:00:00.000000"
["timezone_type"]=>
int(3)
["timezone"]=>
string(16) "Europe/Amsterdam"
}
string(48) "Monday, January 1, 1940 at 12:00:00 AM GMT+00:20"
Additional details
Until 16 May 1940, The Netherlands used UTC+00:20 as timezone. It looks like IntlDateFormatter is not aware of the UTC+00:20 timezone, so it outputs the date in UTC.
The occurrence of the problem seems related to the version of the ICU library:
| Environment | Source | PHP version | ICU version | Output |
|---|---|---|---|---|
| 3v4l.org | https://3v4l.org/UoVSs | 8.2.4 | 57.1 | ✅ As expected |
| Docker + Debian libicu | Dockerfile | 8.2.4 | 67.1 | ❌ Wrong |
| Docker + latest libicu | Dockerfile | 8.2.4 | 72.1 | ❌ Wrong |
I am not familiar enough with the ICU library to assess whether the problem originates there. Since the wrong output is present in PHP when using the latest versions (of PHP and the ICU library), I am submitting the bug here.
PHP Version
8.2.4
Operating System
No response
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Beginne damit, das Beispiel für IntlDateFormatter für Europe/Amsterdam zu reproduzieren, und vergleiche die im Issue aufgeführten ICU-Versionen unter Verwendung der referenzierten Debian- und latest-ICU-Dockerfiles. Verfolge, ob der falsche historische Offset von PHP oder ICU stammt; abgeschlossen ist die Aufgabe, wenn der Formatter das erwartete Ergebnis 1940 UTC+00:20 zurückgibt oder das Issue als Einschränkung von ICU upstream dokumentiert ist.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- php
- Bereich
- internationalization
- Issue-Typ
- Bug
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 38/100