Add a dayPeriod option to Intl.DateTimeFormat() method so the caller can format times such as "7 in the morning", "11 in the morning", "12 noon", "1 in the afternoon", "6 in the evening", "10 at night" (or in Chinese, "清晨7時", "上午11時", "中午12時", "下午1時" ,"下午6時" ,"晚上10時")

Motivation

This enhances Intl.DateTimeFormat() to match what is already possible in C++ and Java by calling ICU and ICU4J. Without this feature, developers need to either format the quarter in the server or ship a set of day period patterns and hour to day period mappings from the server to client to perform such task.

Demo

Documentation

Specification

Public discussion

Status in Chromium

Blink>JavaScript>Internationalization


Enabled by default (tracking bug) in:

  • Chrome for desktop release 92
  • Chrome for Android release 92
  • Android WebView release 92

Consensus & Standardization

After a feature ships in Chrome, the values listed here are not guaranteed to be up to date.

Owners

Intent to Prototype url

Intent to Prototype thread

Comments

dayPeriod is already part of ECMA402 2021. We should launch this to match the standard. It was set to stage in m78 for more than 1.5 years already.

Search tags

Intl, datetimeformat,

Last updated on 2021-04-15