Skip to content

Commit

Permalink
fix: format time locale fallback
Browse files Browse the repository at this point in the history
Signed-off-by: Innei <i@innei.in>
  • Loading branch information
Innei committed Sep 16, 2024
1 parent e31e343 commit 6b1009e
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/renderer/src/components/ui/datetime/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,14 @@ export const RelativeDay = ({ date }: { date: Date }) => {
} else if (diffDays === 1) {
return t("time.yesterday")
} else {
return date.toLocaleDateString(new Intl.Locale(language), {
let locale: Intl.Locale

try {
locale = new Intl.Locale(language.replace("_", "-"))
} catch {
locale = new Intl.Locale("en-US")
}
return date.toLocaleDateString(locale, {
weekday: "long",
month: "short",
day: "numeric",
Expand Down

0 comments on commit 6b1009e

Please sign in to comment.