`Intl.DateTimeFormat().resolvedOptions().timeZone` is `undefined` when `TZ` is a POSIX offset such as `UTC+3`
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 45/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- javascript, nodejs
- Lĩnh vực
- backend, internationalization
Hướng nghiên cứu
The bug is in V8's JSDateTimeFormat::TimeZoneId, which returns undefined when ICU cannot map a POSIX offset to a canonical ID. Start by examining src/objects/js-date-time-format.cc in the Node.js or V8 repository. Look for where icu::TimeZone::getCanonicalID is called and how it handles offset strings. Test with TZ=UTC+3 to reproduce, and check if the fix involves returning an offset string like "-03:00" as per ECMA-262. Run existing intl tests to ensure changes don't break other time zone handling.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Version
v26.5.1 (V8 14.6.202.34-node.24, ICU 78.3). Also reproduces on v22.17.1, v24.11.0 and v25.4.0.
Platform
Linux 7.0.0-31-generic x86_64
Subsystem
intl
What steps will reproduce the bug?
$ TZ=UTC+3 node -p 'Intl.DateTimeFormat().resolvedOptions().timeZone'
undefined
$ TZ=UTC+3 node -p 'new Date().getTimezoneOffset()'
180
TZ=UTC-2 gives undefined as well, with an offset of -120. IANA names are unaffected (TZ=Europe/Paris gives "Europe/Paris", TZ=EST5EDT gives "America/New_York").
How often does it reproduce? Is there a required condition?
Always, when TZ is a POSIX offset string such as UTC+3 that ICU cannot map to a time zone ID.
What is the expected behavior? Why is that the expected behavior?
A string. ECMA-262 SystemTimeZoneIdentifier "returns a String", either a primary time zone identifier or an offset time zone identifier, so here "-03:00" (POSIX UTC+3 is three hours west of UTC, matching getTimezoneOffset() === 180). Formatting already knows the offset: new Intl.DateTimeFormat("en", { timeZoneName: "short" }).format(0) gives 12/31/1969, GMT-3.
What do you see instead?
undefined. Code that keys anything on the zone name (caches, logs, Intl.DateTimeFormat(undefined, { timeZone })) sees the same value for every such offset.
Additional information
The undefined comes from V8's JSDateTimeFormat::TimeZoneId, which returns undefined when icu::TimeZone::getCanonicalID fails, "when the time_zone is neither a known system time zone ID nor a valid custom time zone ID": https://github.com/v8/v8/blob/36de2a2334c9129db7f6fe0db76fd7d5fa64df78/src/objects/js-date-time-format.cc#L612-L635. So this may need forwarding to V8. For comparison, Bun 1.4.0 returns "UTC" in the same environment.
Related but different: #50301 (macOS Sonoma), #26880 (/etc/localtime symlink).
- Ngôn ngữ chính
- JavaScript
- Star
- 122k
- Fork
- 37.4k
- Merge trung bình
- 4 ngày 2 giờ
- Pull request đã merge (30 ngày)
- 277
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.
Issue khác của nodejs/node
-
doc
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
-
build
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 88/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 90/100
-
feature request
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
Issue tương tự
-
Bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
Automattic/safe-publish#594 ·
-
内部文件键(绝对路径的 base64)泄漏到界面标签 Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
dream-num/dsh-univer-office#104 ·
-
comp/dashboard invalid P3
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
NousResearch/hermes-agent#121143 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
avniproject/avni-webapp#1811 ·
-
area/auroraboot area/webui bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100