2022-02-11 17:24:33 +00:00
|
|
|
//https://github.com/you-dont-need/You-Dont-Need-Momentjs
|
|
|
|
|
|
2023-07-13 08:00:49 +00:00
|
|
|
export const locale = Intl.DateTimeFormat().resolvedOptions().locale || 'en-US'
|
2023-03-09 08:00:17 +00:00
|
|
|
// get the user's time zone
|
2023-07-13 08:00:49 +00:00
|
|
|
export const timeZone = Intl.DateTimeFormat().resolvedOptions().timeZone
|
2022-02-11 17:24:33 +00:00
|
|
|
|
|
|
|
|
export function formattedLongDate(rawDate: string): string {
|
|
|
|
|
return new Intl.DateTimeFormat(locale, {
|
|
|
|
|
dateStyle: 'long',
|
2023-03-09 08:00:17 +00:00
|
|
|
timeZone,
|
2022-02-11 17:24:33 +00:00
|
|
|
}).format(new Date(rawDate))
|
|
|
|
|
}
|
|
|
|
|
|
2023-01-16 13:10:05 +00:00
|
|
|
export function formattedShortDate(rawDate: string): string {
|
|
|
|
|
return new Intl.DateTimeFormat(locale, {
|
|
|
|
|
dateStyle: 'short',
|
2023-03-09 08:00:17 +00:00
|
|
|
timeZone,
|
2023-01-16 13:10:05 +00:00
|
|
|
}).format(new Date(rawDate))
|
|
|
|
|
}
|
2023-03-23 01:47:21 +00:00
|
|
|
|
|
|
|
|
export function formattedShortTime(rawDate: string): string {
|
|
|
|
|
return new Intl.DateTimeFormat(locale, {
|
|
|
|
|
timeStyle: 'short',
|
|
|
|
|
timeZone,
|
|
|
|
|
}).format(new Date(rawDate))
|
|
|
|
|
}
|