mirror of
https://github.com/tulir/gomuks.git
synced 2025-04-20 18:43:41 -05:00
Fix time formatting
This commit is contained in:
parent
6b7945c50b
commit
e1600b19ff
1 changed files with 8 additions and 4 deletions
|
@ -17,12 +17,16 @@ interface SetTimezoneProps {
|
|||
const getCurrentTimezone = () => new Intl.DateTimeFormat().resolvedOptions().timeZone
|
||||
|
||||
const currentTimeAdjusted = (tz: string) => {
|
||||
const lang = navigator.language || "en-US"
|
||||
const now = new Date()
|
||||
try {
|
||||
return new Intl.DateTimeFormat(lang, { timeStyle: "long", timeZone: tz }).format(now)
|
||||
return new Intl.DateTimeFormat("en-GB", {
|
||||
hour: "numeric",
|
||||
minute: "numeric",
|
||||
second: "numeric",
|
||||
timeZoneName: "short",
|
||||
timeZone: tz,
|
||||
}).format(new Date())
|
||||
} catch (e) {
|
||||
return `Error: ${e}`
|
||||
return `${e}`
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue