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"
I am trying to build the "long" of either "month" or "weekday". However I am getting the wrong values.