php / php/php-src

`IntlDateFormatter` returns wrong output for 1940 date in Amsterdam timezone

Đang mở
#10,898 6 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Bug Extension: intl Status: Needs Triage
Ngôn ngữ chính
C
Star
40.4k
Fork
8.1k
Merge trung bình
2 ngày 13 giờ
Pull request đã merge (30 ngày)
96

Mô tả

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

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. 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.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Hướng nghiên cứu

Bắt đầu bằng cách tái hiện ví dụ IntlDateFormatter cho Europe/Amsterdam và so sánh các phiên bản ICU được liệt kê trong issue, sử dụng các Dockerfile Debian và latest-ICU được tham chiếu. Truy tìm xem offset lịch sử không chính xác bắt nguồn từ PHP hay ICU; được coi là hoàn tất khi formatter trả về kết quả 1940 UTC+00:20 như mong đợi hoặc issue được ghi nhận là một giới hạn upstream của ICU.

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
internationalization
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
38/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.