← Back to release summary

Add dayPeriod option for Intl.DateTimeFormat

Category
JavaScript
Type
Chromium catches up
Status
Enabled by default (Chrome 92)
Intent stage
Prepare to ship

Summary

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.

Standards & signals

Docs: https://tc39.es/ecma402/#table-datetimeformat-components https://tc39.es/ecma402/#sec-todatetimeoptions https://tc39.es/ecma402/#sec-intl.datetimeformat-internal-slots https://tc39.es/ecma402/#table-datetimeformat-rangepatternfields https://github.com/tc39/ecma402/pull/346

Samples: https://github.com/tc39/ecma402/pull/346

Explainers: https://docs.google.com/document/d/10l10gpw5hBdZ1OuYVqZPU72-61yyOaTUQllIVRyQoFM/edit#

View on chromestatus.com