Respect timezone offset given after timezone name
Chưa có ai nhận issue này.
- Ngôn ngữ chính
- C
- Star
- 40.4k
- Fork
- 8.2k
- Merge trung bình
- 2 ngày 15 giờ
- Pull request đã merge (30 ngày)
- 103
Mô tả
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)
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Hướng nghiên cứu
Tái hiện hành vi bằng hàm tạo DateTime với tên America/Toronto và offset -0500, sau đó so sánh với ví dụ về @timestamp và setTimezone. Truy vết điểm vào của quá trình phân tích ngày giờ và bổ sung coverage cho cả hai offset hợp lệ vào ngày 3 tháng 11 năm 2024; hoàn thành khi offset tường minh được tôn trọng nếu nó xác định một thời gian cục bộ tồn tại, đồng thời hành vi hiện tại vẫn được giữ nguyên đối với các tổ hợp không hợp lệ.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- php
- Lĩnh vực
- backend
- Loại issue
- Lỗi
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Khá rõ ràng
- Mức phù hợp với người mới
- 34/100