I want to store a DateTimeFormatOptions
for date.toLocaleString()
to use in multiple places in my app. I defined it like:
export const timeFormat = { month: 'numeric', day: '2-digit', hour: '2-digit', minute: '2-digit', hour12: false, timeZoneName: 'short', time Zone: 'UTC'}
And I get:
Argument of type '{ month: string; day: string; hour: string; minute: string; hour12: boolean; timeZoneName: string; timeZone: string; }' is not assignable to parameter of type 'DateTimeFormatOptions'.
Types of property 'month' are incompatible.
Type 'string' is not assignable to type '"numeric" | "2-digit" | "short" | "long" | "narrow" | undefined'.
But I can't figure out import DateTimeFormatOptions. Eventually I just wrote a helper method that formats the date, but I still may need to import it because I may allow the user to change date preferences.