diff --git a/src/app/(dashboard)/peer/page.tsx b/src/app/(dashboard)/peer/page.tsx index a5cd5504..bd217b0b 100644 --- a/src/app/(dashboard)/peer/page.tsx +++ b/src/app/(dashboard)/peer/page.tsx @@ -628,7 +628,7 @@ function PeerInformationCard({ peer }: Readonly<{ peer: Peer }>) { > } value={ - dayjs(peer.created_at).format("D MMMM, YYYY [at] h:mm A") + + dayjs(peer.created_at).format("L [at] LT") + " (" + dayjs().to(peer.created_at) + ")" @@ -646,7 +646,7 @@ function PeerInformationCard({ peer }: Readonly<{ peer: Peer }>) { value={ peer.connected ? "just now" - : dayjs(peer.last_seen).format("D MMMM, YYYY [at] h:mm A") + + : dayjs(peer.last_seen).format("L [at] LT") + " (" + dayjs().to(peer.last_seen) + ")" diff --git a/src/app/(dashboard)/team/user/page.tsx b/src/app/(dashboard)/team/user/page.tsx index 39fd7873..04be94ef 100644 --- a/src/app/(dashboard)/team/user/page.tsx +++ b/src/app/(dashboard)/team/user/page.tsx @@ -402,7 +402,7 @@ function UserInformationCard({ user }: Readonly<{ user: User }>) { value={ neverLoggedIn ? "Never" - : dayjs(user.last_login).format("D MMMM, YYYY [at] h:mm A") + + : dayjs(user.last_login).format("L [at] LT") + " (" + dayjs().to(user.last_login) + ")" diff --git a/src/app/invite/page.tsx b/src/app/invite/page.tsx index 175afd34..6919c4dd 100644 --- a/src/app/invite/page.tsx +++ b/src/app/invite/page.tsx @@ -300,7 +300,7 @@ function InviteAcceptContent() {
- Invite expires on {dayjs(inviteInfo.expires_at).format("D MMMM, YYYY [at] h:mm A")} + Invite expires on {dayjs(inviteInfo.expires_at).format("L [at] LT")}
@@ -318,4 +318,4 @@ function PasswordRule({ met, text }: { met: boolean; text: string }) { {text} ); -} \ No newline at end of file +} diff --git a/src/components/DatePickerWithRange.tsx b/src/components/DatePickerWithRange.tsx index 874063c8..29cd5b46 100644 --- a/src/components/DatePickerWithRange.tsx +++ b/src/components/DatePickerWithRange.tsx @@ -87,10 +87,10 @@ export function DatePickerWithRange({ if (isActive.yesterday) return "Yesterday"; if (isActive.today) return "Today"; - if (!value.to) return dayjs(value.from).format("MMM DD, YYYY").toString(); - return `${dayjs(value.from).format("MMM DD, YYYY")} - ${dayjs( + if (!value.to) return dayjs(value.from).format("L").toString(); + return `${dayjs(value.from).format("L")} - ${dayjs( value.to, - ).format("MMM DD, YYYY")}`; + ).format("L")}`; }, [value, isActive]); const [calendarOpen, setCalendarOpen] = useState(false); diff --git a/src/layouts/AppLayout.tsx b/src/layouts/AppLayout.tsx index bd421e01..673c976e 100644 --- a/src/layouts/AppLayout.tsx +++ b/src/layouts/AppLayout.tsx @@ -6,6 +6,7 @@ import { TooltipProvider } from "@components/Tooltip"; import { cn } from "@utils/helpers"; import dayjs from "dayjs"; import relativeTime from "dayjs/plugin/relativeTime"; +import localizedFormat from "dayjs/plugin/localizedFormat"; import { Viewport } from "next"; import localFont from "next/font/local"; import React, { Suspense } from "react"; @@ -28,6 +29,34 @@ const inter = localFont({ // Extend dayjs with relativeTime plugin dayjs.extend(relativeTime); +// Extend dayjs with localizedFormat plugin +dayjs.extend(localizedFormat); + +(() => { + if (typeof window !== "undefined") { + const languages = Array.of(navigator.language, navigator.languages).flat(); + let candidates = new Set(); + + for (let language of languages) { + language = language.toLowerCase(); + candidates.add(language); + candidates.add(language.split("-")[0]); + } + + (async () => { + for (const locale of candidates) { + try { + await import(`dayjs/locale/${locale}`); + dayjs.locale(locale); + return; + } catch { + // try next candidate + } + } + dayjs.locale("en"); + })(); + } +})(); export const viewport: Viewport = { width: "device-width", diff --git a/src/modules/activity/ActivityEntryRow.tsx b/src/modules/activity/ActivityEntryRow.tsx index 5a10a045..df7d1ccc 100644 --- a/src/modules/activity/ActivityEntryRow.tsx +++ b/src/modules/activity/ActivityEntryRow.tsx @@ -120,7 +120,7 @@ export const ActivityEntryRow = ({ event }: { event: ActivityEvent }) => { className={"flex gap-2 items-center text-nb-gray-400 text-xs mr-1"} > - {dayjs(event?.timestamp).format("MMM D, YYYY [at] h:mm:s A")} + {dayjs(event?.timestamp).format("L [at] LT")} diff --git a/src/modules/common-table-rows/ExpirationDateRow.tsx b/src/modules/common-table-rows/ExpirationDateRow.tsx index eded03d6..75794c0b 100644 --- a/src/modules/common-table-rows/ExpirationDateRow.tsx +++ b/src/modules/common-table-rows/ExpirationDateRow.tsx @@ -12,7 +12,7 @@ export default function ExpirationDateRow({ date }: Props) { } >