Intl.DateTimeFormat 中 dayPeriod 的參考 (Reference for dayPeriod in Intl.DateTimeFormat)


問題描述

Intl.DateTimeFormat 中 dayPeriod 的參考 (Reference for dayPeriod in Intl.DateTimeFormat)

什麼是 JavaScript Intl.DateTimeFormat 中的 dayPeriod,在 en‑US 語言環境中可以採用哪些值?另外,它在最近的瀏覽器中是否有廣泛的支持?

我似乎找不到任何參考。


參考解法

方法 1:

The only reference I could find was this Unicode Common Locale Data Repository (CLDR) table, and the associated downloads page. I am not sure how browsers implement it.

Fun fact, the number of day periods varies across locales. English has 4 (morning, afternoon, evening, night), while for example German has 6.

An excerpt from the xml file:

<dayPeriodRules locales="root">
    <dayPeriodRule type="am" from="00:00" before="12:00"/>  <!‑‑ AM ‑‑>
    <dayPeriodRule type="pm" from="12:00" before="24:00"/>  <!‑‑ PM ‑‑>
</dayPeriodRules>
<dayPeriodRules locales="en">
    <dayPeriodRule type="midnight" at="00:00"/> <!‑‑ midnight ‑‑>
    <dayPeriodRule type="noon" at="12:00"/> <!‑‑ noon ‑‑>
    <dayPeriodRule type="morning1" from="06:00" before="12:00"/>    <!‑‑ morning ‑‑>
    <dayPeriodRule type="afternoon1" from="12:00" before="18:00"/>  <!‑‑ afternoon ‑‑>
    <dayPeriodRule type="evening1" from="18:00" before="21:00"/>    <!‑‑ evening ‑‑>
    <dayPeriodRule type="night1" from="21:00" before="06:00"/>  <!‑‑ night ‑‑>
</dayPeriodRules>

(by ChristopheChristophe)

參考文件

  1. Reference for dayPeriod in Intl.DateTimeFormat (CC BY‑SA 2.5/3.0/4.0)

#internationalization #datetime-format #javascript






相關問題

志願者翻譯對 Delphi 2009 應用程序進行本地化的過程? (Process for localization of Delphi 2009 app by volunteer translators?)

Netbeans 菜單和 i18n (Netbeans menu and i18n)

Menggunakan Perpustakaan Penutupan pada aplikasi Phonegap (Android) (Using Closure Library on Phonegap(Android) application)

支持 SDK 但不支持 PhoneGap 的印度語語言 (Indic Language Support for SDK but not PhoneGap)

翻譯 symfony2 路由錯誤 (translation symfony2 routing error)

Django 沒有正確翻譯網站 (Django not translating the site properly)

django模型翻譯404 (django modeltranslation 404)

您是否知道用於編輯/翻譯資源(.rc)文件的好的程序? (Do you know of a good program for editing/translating resource (.rc) files?)

Struts 2 動作調用丟失 xwork i18n 語言設置 (Struts 2 action call loses the xwork i18n language setting)

移動應用測試 (Mobile application testing)

nuxt-i18n 的延遲加載語言環境 (Lazy load locales for nuxt-i18n)

你能在 next.config 中獲取數據嗎 (Can you fetch data in next.config)







留言討論