tc39 / proposal-intl-formatToParts

Intl 402 spec proposal for {DateTimeFormat,Number}.prototype.formatToParts
17 stars 17 forks source link

"long" returns wrong value #6

Open ellioseven opened 5 years ago

ellioseven commented 5 years ago

I am trying to build the "long" of either "month" or "weekday". However I am getting the wrong values.

const date = Date.now()

// Get part from date format parts.
const get = (key, parts) =>
  parts.find(({ type }) => type === key)

// Date format defaults.
const options = {
  timeZone: "Australia/Sydney",
  weekday: "long",
  year: "numeric",
  month: "numeric",
  day: "numeric",
  hour: "2-digit",
  minute: "2-digit",
  hour12: true
}

const parts = new Intl.DateTimeFormat("en", options)
  .formatToParts(date)

// A full textual representation of the day of the week eg: Tuesday.
const value = get("weekday", parts).value

// Expect: "Monday"
// Result: "Mon"
ellioseven commented 4 years ago

In the mean time I've had to implement my own work around to correctly display month and weekday. Can I get anyone to take a look at this bug for me?