For AI agents: the complete documentation index is available at /tc39-atlas/llms.txt, the full documentation bundle is available at /tc39-atlas/llms-full.txt, and this page is available as Markdown at /tc39-atlas/proposals/stage/4/proposal-intl-extend-timezonename.md.
  • 简体中文
  • Extend TimeZoneName Option Proposal S4

    中文标题:扩展 TimeZoneName 选项提案

    提案概览
    提案速览

    该提案扩展了 Intl.DateTimeFormat 中的 timeZoneName 选项,以支持四种新格式:shortOffset、longOffset、shortGeneric 和 longGeneric,超越了现有的 short 和 long。它旨在根据 UTS35 提供更灵活的时区显示选项。

    Note

    以下 README 来自上游仓库,其中的阶段或状态标注可能滞后;当前信息以提案概览为准。

    扩展 TimeZoneName 选项提案

    阶段

    阶段 3

    倡导者

    • Frank Tang @FrankYFTang

    阶段 3 审查者(阶段 2 期间需要)

    • Philip Chimento @ptomato
    • Rick Button @rickbutton

    编辑

    • 待定

    范围

    扩展 Intl.DateTimeFormat 对象中的 timeZoneName 选项,以支持更多格式化选项。

    背景

    先前的讨论: ECMA402#119 DateTimeFormat: 考虑添加更多时区显示选项

    参考: UTS35 - "7 使用时区名称"

    更新的提案 - 仅添加 4 种新格式

    timeZoneNameCLDR 模式示例UTS35 中的描述ICU 键在 476 个区域设置中的总项目数UTF8 总字节数压缩大小
    shortOffsetOGMT-8短本地化 GMT 格式。zone/*/zoneStrings/gmt.*Format2631826392
    longOffsetOOOOGMT-0800长本地化 GMT 格式。(同上)(与上面无额外)(与上面无额外)(与上面无额外)
    shortGenericvPT短通用非位置格式。zone/*/zoneStrings/meta:*/sg3321719311
    longGenericvvvvPacific Time长通用非位置格式。zone/*/zoneStrings/meta:*/lg1004727810369526

    注意: 以下是我如何得到上述数字的

    $ cd icu/icu4c/source/data/zone
    $ egrep "sg\{" *|cut -d\" -f2 |wc
        332     333    1719
    $ egrep "sg\{" *|cut -d\" -f2 | gzip -f |wc -c
    311
    $ egrep "lg\{" *|cut -d\" -f2 |wc 
      10047   24026  278103 
    $ egrep "lg\{" *|cut -d\" -f2 | gzip -f |wc -c
    69526
    $ egrep "gmt.*Format\{" *|cut -d\" -f2 |wc
        263     284    1826
    $ egrep "gmt.*Format\{" *|cut -d\" -f2 | gzip -f |wc -c
    392

    追踪

    V8 对更新后的提案的输出

    $ out/x64.release/d8 --harmony_intl_more_timezone
    V8 version 8.9.0 (candidate)
    d8> let timeZoneNames = ["short", "long", "shortOffset", "longOffset", "shortGeneric", "longGeneric"];
    d8> timeZoneNames.forEach(function(timeZoneName) { print(timeZoneName + ": " + (new Date()).toLocaleTimeString("en", {timeZoneName}))});
    d8> timeZoneNames.forEach(function(timeZoneName) { print(timeZoneName + ": " + (new Date()).toLocaleTimeString("en", {timeZoneName}))});
    short: 12:27:10 PM PST
    long: 12:27:10 PM Pacific Standard Time
    shortOffset: 12:27:10 PM GMT-8
    longOffset: 12:27:10 PM GMT-08:00
    shortGeneric: 12:27:10 PM PT
    longWall: 12:27:10 PM Pacific Time
    
    
    d8> timeZoneNames.forEach(function(timeZoneName) { print(timeZoneName + ": " + (new Date()).toLocaleTimeString("zh-Hant", {timeZoneName}))});
    short: 下午12:26:20 [PST]
    long: 下午12:26:20 [太平洋標準時間]
    shortOffset: 下午12:26:20 [GMT-8]
    longOffset: 下午12:26:20 [GMT-08:00]
    shortGeneric: 下午12:26:20 [PT]
    longGeneric: 下午12:26:20 [太平洋時間]
    
    
    d8> timeZoneNames.forEach(function(timeZoneName) { print(timeZoneName + ": " + (new Date()).toLocaleTimeString("en", {timeZoneName, timeZone: "Asia/Calcutta"}))});
    short: 1:54:56 AM GMT+5:30
    long: 1:54:56 AM India Standard Time
    shortOffset: 1:54:56 AM GMT+5:30
    longOffset: 1:54:56 AM GMT+05:30
    shortGeneric: 1:54:56 AM India Time
    longGeneric: 1:54:56 AM India Standard Time
    

    参见 由于大小问题可能被移除的选项存档的 README.md

    阶段推进计划

    阶段 2 的进入标准

    阶段 1 的进入标准

    • 确定了将推进该添加的“倡导者”: 已完成- @FrankYFTang
    • 概述问题或需求以及解决方案总体形态的散文 已完成
    • 用法示例 已完成
    • 高层级 API 已完成
    • 关键算法、抽象和语义的讨论 已完成
    • 识别潜在的“跨领域”问题以及实现挑战/复杂度 已完成
    • 一个公开可用的提案仓库,包含上述要求: 已完成 https://github.com/tc39/proposal-intl-extend-timezonename/
    • 接受意味着: “委员会期望投入时间审查问题空间、解决方案和跨领域问题”