1 of 9

Intl.DateTimeFormat

dateStyle / timeStyle

For Stage 4

Champions:

Zibi Braniecki (Mozilla)

Reviewers:

Frank Tang (Google)

Nathan Hammond (Ember)

2 of 9

Motivation

  • Compact way to request date and time of given lengths
  • Styles are more locale-specific than option bags
  • Better matching OS internationalization settings

3 of 9

Options Bag

let dtf = new Intl.DateTimeFormat("pl", {

year: "numeric", // "numeric", "2-digit"

month: "short", // "short", "numeric", "2-digit"

day: "numeric", // "numeric", "2-digit"

});

console.log(dtf.format(date)); // "18 lip 2020"

4 of 9

dateStyle

let dtf = new Intl.DateTimeFormat("pl", {

dateStyle: "medium", // "full", "long", "medium" or "short"

});

console.log(dtf.format(date)); // "18 lip 2020"

5 of 9

timeStyle

let dtf = new Intl.DateTimeFormat("pl", {

timeStyle: "medium", // "full", "long", "medium" or "short"

});

console.log(dtf.format(date)); // "18:40:42"

6 of 9

dateStyle + timeStyle

let dtf = new Intl.DateTimeFormat("pl", {

dateStyle: "long", // "full", "long", "medium" or "short"

timeStyle: "short", // "full", "long", "medium" or "short"

});

console.log(dtf.format(date)); // "18 lipca 2020 18:42"

7 of 9

Current Status

  • Stage 3 since March 26th 2019
  • Shipped in:
    • Firefox 79
    • Chrome 76
    • Node 13
  • Full test262 coverage
  • MDN documentation
  • Pull Request: #457 (several minor editorial comments with consensus)
  • Editor sign-off: by @leobalter, @sffc

8 of 9

Plans for v2

  • Interoperability with Temporal

9 of 9

Requesting the Committee Approval for advancement to Stage 4