Respect timezone offset given after timezone name
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
Hello 👋 With the following code:
<?php
$date = new DateTime('2024-11-03 01:30:00 America/Toronto -0500');
echo $date->format('Y-m-d H:i:s e O');
Resulted in this output:
2024-11-03 01:30:00 America/Toronto -0400
But I expected this output instead:
2024-11-03 01:30:00 America/Toronto -0500
Both exist, and it's possible to obtain the first with:
$date = new DateTime('@1730611800');
$date->setTimezone(new DateTimeZone('America/Toronto'));
As per the test above, it sounds like whatever offset coming after a named timezone like "America/Toronto" is ignored, so we can have the timezone set by name or by offset but we cannot have both while it's actually needed to distinguish 2 possibly different moments during DST such as Nov 3rd 1:30 -0400 and Nov 3rd 1:30 -0500 which both exist in America/Toronto.
A possible implementation would to:
- Detect both named timezone and offset timezone,
- if only one is present:
- no change: keep current behavior
- if both are present:
- and the current date-time + timezone offset exist in the given timezone city
- apply both
- but the current date-time + timezone offset is invalid
- ignore offset (i.e. current behavior)
- and the current date-time + timezone offset exist in the given timezone city
Thanks 🙏
PHP Version
PHP 8.3.12 and also 8.4.0-dev (78767de197d1b2a6d2dd2757258b4c642bda8052)
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
Reproduziere das Verhalten mit dem DateTime-Konstruktor unter Verwendung des Namens America/Toronto und des Offsets -0500 und vergleiche es anschließend mit dem Beispiel für @timestamp und setTimezone. Verfolge den Einstiegspunkt der Date-Time-Analyse und füge Tests für beide gültigen Offsets am 3. November 2024 hinzu; fertig ist es, wenn der explizite Offset berücksichtigt wird, sofern er eine vorhandene lokale Zeit identifiziert, und das aktuelle Verhalten für ungültige Kombinationen erhalten bleibt.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- php
- Bereich
- backend
- Issue-Typ
- Bug
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 34/100