mirror of
https://github.com/omnivore-app/omnivore.git
synced 2026-03-11 08:54:26 +00:00
Use local timezone for the date in the reader
This commit is contained in:
parent
78f8fa1726
commit
dd7a4e4eac
1 changed files with 4 additions and 0 deletions
|
|
@ -1,15 +1,19 @@
|
|||
//https://github.com/you-dont-need/You-Dont-Need-Momentjs
|
||||
|
||||
const locale = Intl.DateTimeFormat().resolvedOptions().locale || 'en-US'
|
||||
// get the user's time zone
|
||||
const timeZone = Intl.DateTimeFormat().resolvedOptions().timeZone
|
||||
|
||||
export function formattedLongDate(rawDate: string): string {
|
||||
return new Intl.DateTimeFormat(locale, {
|
||||
dateStyle: 'long',
|
||||
timeZone,
|
||||
}).format(new Date(rawDate))
|
||||
}
|
||||
|
||||
export function formattedShortDate(rawDate: string): string {
|
||||
return new Intl.DateTimeFormat(locale, {
|
||||
dateStyle: 'short',
|
||||
timeZone,
|
||||
}).format(new Date(rawDate))
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue