Skip to content

hourCycle may affect field widths #454

@zbraniecki

Description

@zbraniecki

[...] because CLDR/ICU may give different field widths for different hour-cycles. For example, hour is "numeric" for "h12", but "2-digit" for "h23" for "en".

Hmm, this actually already a problem in the main ECMA-402 spec when compared to what's implemented in engines:

js> new Date("2020-01-01T01:02:03").toLocaleString("en-u-hc-h12")
"1/1/2020, 1:02:03 AM"
js> new Date("2020-01-01T01:02:03").toLocaleString("en-u-hc-h23") 
"1/1/2020, 01:02:03"

Per spec it is illegal to format hour once as "1" and another time as "01". So I think you can punt on the issue about different field widths for [[pattern]] and [[pattern12]], and use this record structure:

[[short]]: {
  [[pattern]]: "{hour}:{minute}",
  [[pattern12]]: "{hour}:{minute} {ampm}",
  [[hour]]: "2-digit",
  [[minute]]: "2-digit",
}

Originally posted by @anba in tc39/proposal-intl-datetime-style#45 (comment)

Metadata

Metadata

Assignees

No one assigned

    Labels

    DataRelated to locale dataSmallSmaller change solvable in a Pull Requestc: datetimeComponent: dates, times, timezoness: help wantedStatus: help wanted; needs proposal champion

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions