Respect timezone offset given after timezone name
まだ誰も着手していません。
- 主要言語
- C
- スター
- 40.4k
- フォーク
- 8.2k
- 平均マージ
- 2日 13時間
- マージ済み PR(30日)
- 96
説明
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)
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
America/Toronto の名前と -0500 オフセットを使用した DateTime コンストラクターで動作を再現し、その後 @timestamp と setTimezone の例と比較します。日時解析のエントリーポイントを追跡し、2024 年 11 月 3 日の両方の有効なオフセットについてカバレッジを追加します。既存のローカル時刻を識別する場合は明示的なオフセットが尊重され、無効な組み合わせでは現在の動作が維持されれば完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- php
- 領域
- backend
- issue の種類
- バグ
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 34/100