Open-source event management and ticket selling platform — perfect for concerts, conferences, and everything in between 🎟️ If you find this project helpful, please consider giving us a star ⭐️
PHP attendize-alternativedoor-managementevent-check-inevent-managementevent-registrationevent-ticketingeventbrite-alternativeeventslaravelopen-sourcephpreactself-hostedsell-ticketssell-tickets-onlineticket-sellingticketing-systemtickettailor-alternativetito-alternative
Feature: Enhance date formatting with user locale support (#782)
YoranSysbd6b8bd2fa2b
diff --git a/frontend/src/components/common/EventCard/index.tsx b/frontend/src/components/common/EventCard/index.tsxindex 54285c15c..f7c78fffd 100644--- a/frontend/src/components/common/EventCard/index.tsx+++ b/frontend/src/components/common/EventCard/index.tsx@@ -27,7 +27,7 @@ import {showError, showSuccess} from "../../../utilites/notifications.tsx";import {useUpdateEventStatus} from "../../../mutations/useUpdateEventStatus.ts";import {formatCurrency} from "../../../utilites/currency.ts";import {formatNumber} from "../../../utilites/helpers.ts";-import {formatDate} from "../../../utilites/dates.ts";+import {formatDateWithLocale} from "../../../utilites/dates.ts";const placeholderEmojis = ['🎉', '🎪', '🎸', '🎨', '🌟', '🎭', '🎯', '🎮', '🎲', '🎳'];@@ -137,15 +137,15 @@ export function EventCard({event}: EventCardProps) {<div className={classes.dateTime}><div className={classes.dateBox}><span- className={classes.month}>{formatDate(event.start_date, 'MMM', event.timezone)}</span>- <span className={classes.day}>{formatDate(event.start_date, 'D', event.timezone)}</span>+ className={classes.month}>{formatDateWithLocale(event.start_date, 'monthShort', event.timezone)}</span>+ <span className={classes.day}>{formatDateWithLocale(event.start_date, 'dayOfMonth', event.timezone)}</span></div><div className={classes.timeInfo}><span- className={classes.time}>{formatDate(event.start_date, 'h:mm A', event.timezone)}</span>+ className={classes.time}>{formatDateWithLocale(event.start_date, 'timeOnly', event.timezone)}</span>{event.end_date && (<span- className={classes.endTime}>- {formatDate(event.end_date, 'h:mm A', event.timezone)}</span>+ className={classes.endTime}>- {formatDateWithLocale(event.end_date, 'timeOnly', event.timezone)}</span>)}</div></div>diff --git a/frontend/src/components/common/EventDateRange/index.tsx b/frontend/src/components/common/EventDateRange/index.tsxindex 64411fb77..89c2ba9fb 100644--- a/frontend/src/components/common/EventDateRange/index.tsx+++ b/frontend/src/components/common/EventDateRange/index.tsx@@ -1,32 +1,35 @@-import {Event} from "../../../types.ts";-import {formatDate} from "../../../utilites/dates.ts";+import { Event } from "../../../types.ts";+import { formatDateWithLocale } from "../../../utilites/dates.ts";interface EventDateRangeProps {- event: Event+ event: Event;}-export const EventDateRange = ({event}: EventDateRangeProps) => {- const startDateFormatted = formatDate(event.start_date, "ddd, MMM D, YYYY h:mm A", event.timezone);- const endDateFormatted = event.end_date ? formatDate(event.end_date, "ddd, MMM D, YYYY h:mm A", event.timezone) : null;- const sameDayFormatted = formatDate(event.start_date, "dddd, MMMM D", event.timezone);- const startTimeFormatted = formatDate(event.start_date, "h:mm A", event.timezone);- const endTimeFormatted = event.end_date ? formatDate(event.end_date, "h:mm A", event.timezone) : null;- const timezone = formatDate(event.start_date, "z", event.timezone);-+export const EventDateRange = ({ event }: EventDateRangeProps) => {const isSameDay = event.end_date && event.start_date.substring(0, 10) === event.end_date.substring(0, 10);+ const timezone = formatDateWithLocale(event.start_date, "timezone", event.timezone);++ if (isSameDay) {+ const dayFormatted = formatDateWithLocale(event.start_date, "dayName", event.timezone);+ const startTime = formatDateWithLocale(event.start_date, "timeOnly", event.timezone);+ const endTime = formatDateWithLocale(event.end_date!, "timeOnly", event.timezone);++ return (+ <span>+ {dayFormatted} · {startTime} - {endTime} {timezone}+ </span>+ );+ }++ const startDateFormatted = formatDateWithLocale(event.start_date, "fullDateTime", event.timezone);+ const endDateFormatted = event.end_date+ ? formatDateWithLocale(event.end_date, "fullDateTime", event.timezone)+ : null;return (- <>- {isSameDay ? (- <span>- {sameDayFormatted} · {startTimeFormatted} - {endTimeFormatted} {timezone}- </span>- ) : (- <span>- {startDateFormatted}- {endDateFormatted && ` - ${endDateFormatted}`} {timezone}- </span>- )}- </>+ <span>+ {startDateFormatted}+ {endDateFormatted && ` - ${endDateFormatted}`} {timezone}+ </span>);}diff --git a/frontend/src/components/layouts/OrganizerHomepage/EventCard/index.tsx b/frontend/src/components/layouts/OrganizerHomepage/EventCard/index.tsxindex 25c1ecb8e..84c3170e7 100644--- a/frontend/src/components/layouts/OrganizerHomepage/EventCard/index.tsx+++ b/frontend/src/components/layouts/OrganizerHomepage/EventCard/index.tsx@@ -2,7 +2,7 @@ import React from 'react';import {Link} from "react-router";import {Event} from "../../../../types.ts";import classes from './EventCard.module.scss';-import {formatDate} from "../../../../utilites/dates.ts";+import {formatDateWithLocale} from "../../../../utilites/dates.ts";import {t} from "@lingui/macro";import {isLightColor} from "@mantine/core";import {formatCurrency} from "../../../../utilites/currency.ts";@@ -26,15 +26,15 @@ export const EventCard: React.FC<EventCardProps> = ({event, primaryColor = '#8b5const placeholderEmoji = placeholderEmojis[emojiIndex];// Format dates using the event's timezone- const startMonth = formatDate(event.start_date, "MMM", event.timezone);- const startDay = formatDate(event.start_date, "D", event.timezone);- const startTime = formatDate(event.start_date, "h:mm A", event.timezone);- const endTime = event.end_date ? formatDate(event.end_date, "h:mm A", event.timezone) : null;- const prettyTimezone = formatDate(event.start_date, "z", event.timezone);+ const startMonth = formatDateWithLocale(event.start_date, "monthShort", event.timezone);+ const startDay = formatDateWithLocale(event.start_date, "dayOfMonth", event.timezone);+ const startTime = formatDateWithLocale(event.start_date, "timeOnly", event.timezone);+ const endTime = event.end_date ? formatDateWithLocale(event.end_date, "timeOnly", event.timezone) : null;+ const prettyTimezone = formatDateWithLocale(event.start_date, "timezone", event.timezone);const isSameDay = event.end_date && event.start_date.substring(0, 10) === event.end_date.substring(0, 10);- const endMonth = event.end_date ? formatDate(event.end_date, "MMM", event.timezone) : null;- const endDay = event.end_date ? formatDate(event.end_date, "D", event.timezone) : null;+ const endMonth = event.end_date ? formatDateWithLocale(event.end_date, "monthShort", event.timezone) : null;+ const endDay = event.end_date ? formatDateWithLocale(event.end_date, "dayOfMonth", event.timezone) : null;const coverImage = event.images?.find(img => img.type === 'EVENT_COVER');const location = event?.settings?.location_details?.city || event?.settings?.location_details?.venue_name;diff --git a/frontend/src/components/routes/event/EventDashboard/index.tsx b/frontend/src/components/routes/event/EventDashboard/index.tsxindex 8cd14b5f9..0e5d04d27 100644--- a/frontend/src/components/routes/event/EventDashboard/index.tsx+++ b/frontend/src/components/routes/event/EventDashboard/index.tsx@@ -10,7 +10,7 @@ import {Card} from "../../../common/Card";import classes from "./EventDashboard.module.scss";import {useGetEventStats} from "../../../../queries/useGetEventStats.ts";import {formatCurrency} from "../../../../utilites/currency.ts";-import {formatDate} from "../../../../utilites/dates.ts";+import {formatDateWithLocale} from "../../../../utilites/dates.ts";import {Button, Skeleton} from "@mantine/core";import {useMediaQuery} from "@mantine/hooks";import {IconAlertCircle, IconX} from "@tabler/icons-react";@@ -87,7 +87,7 @@ export const EventDashboard = () => {}const dateRange = (eventStats && event)- ? `${formatDate(eventStats.start_date, 'MMM DD', event?.timezone)} - ${formatDate(eventStats.end_date, 'MMM DD', event?.timezone)}`+ ? `${formatDateWithLocale(eventStats.start_date, 'chartDate', event?.timezone)} - ${formatDateWithLocale(eventStats.end_date, 'chartDate', event?.timezone)}`: '';const shouldShowChecklist = (isChecklistVisible && event && accountIsFetched && account?.is_saas_mode_enabled) && (@@ -255,7 +255,7 @@ export const EventDashboard = () => {<AreaCharth={300}data={eventStats?.daily_stats.map(stat => ({- date: formatDate(stat.date, 'MMM DD', event.timezone),+ date: formatDateWithLocale(stat.date, 'chartDate', event.timezone),orders_created: stat.orders_created,products_sold: stat.products_sold,attendees_registered: stat.attendees_registered,@@ -289,7 +289,7 @@ export const EventDashboard = () => {h={300}data={eventStats?.daily_stats.map(stat => {return ({- date: formatDate(stat.date, 'MMM DD', event.timezone),+ date: formatDateWithLocale(stat.date, 'chartDate', event.timezone),total_fees: stat.total_fees,total_sales_gross: stat.total_sales_gross,total_tax: stat.total_tax,diff --git a/frontend/src/components/routes/event/Reports/DailySalesReport/index.tsx b/frontend/src/components/routes/event/Reports/DailySalesReport/index.tsxindex a78b188b4..632e23f0c 100644--- a/frontend/src/components/routes/event/Reports/DailySalesReport/index.tsx+++ b/frontend/src/components/routes/event/Reports/DailySalesReport/index.tsx@@ -1,7 +1,7 @@import {useParams} from "react-router";import {useGetEvent} from "../../../../../queries/useGetEvent.ts";import {formatCurrency} from "../../../../../utilites/currency.ts";-import {formatDate} from "../../../../../utilites/dates.ts";+import {formatDateWithLocale} from "../../../../../utilites/dates.ts";import ReportTable from "../../../../common/ReportTable";export const DailySalesReport = () => {@@ -18,7 +18,7 @@ export const DailySalesReport = () => {key: 'date' as const,label: 'Date',sortable: true,- render: (value: string) => formatDate(value, 'MMM D, YYYY', event?.timezone)+ render: (value: string) => formatDateWithLocale(value, 'shortDate', event?.timezone)},{key: 'sales_total_gross' as const,diff --git a/frontend/src/components/routes/event/Reports/PromoCodesReport/index.tsx b/frontend/src/components/routes/event/Reports/PromoCodesReport/index.tsxindex d23b13ed6..f9d849a8e 100644--- a/frontend/src/components/routes/event/Reports/PromoCodesReport/index.tsx+++ b/frontend/src/components/routes/event/Reports/PromoCodesReport/index.tsx@@ -3,7 +3,7 @@ import {useGetEvent} from "../../../../../queries/useGetEvent.ts";import {formatCurrency} from "../../../../../utilites/currency.ts";import ReportTable from "../../../../common/ReportTable";import {t} from "@lingui/macro";-import {formatDate} from "../../../../../utilites/dates.ts";+import {formatDateWithLocale} from "../../../../../utilites/dates.ts";const PromoCodesReport = () => {const {eventId} = useParams();@@ -63,13 +63,13 @@ const PromoCodesReport = () => {key: 'first_used_at' as const,label: t`First Used`,sortable: true,- render: (value: string) => value ? formatDate(value, 'MMM D, YYYY', event.timezone) : '-'+ render: (value: string) => value ? formatDateWithLocale(value, 'shortDate', event.timezone) : '-'},{key: 'last_used_at' as const,label: t`Last Used`,sortable: true,- render: (value: string) => value ? formatDate(value, 'MMM D, YYYY', event.timezone) : '-'+ render: (value: string) => value ? formatDateWithLocale(value, 'shortDate', event.timezone) : '-'},{key: 'max_allowed_usages' as const,diff --git a/frontend/src/components/routes/organizer/Reports/CheckInSummaryReport/index.tsx b/frontend/src/components/routes/organizer/Reports/CheckInSummaryReport/index.tsxindex 0de4c32d3..612c0c20d 100644--- a/frontend/src/components/routes/organizer/Reports/CheckInSummaryReport/index.tsx+++ b/frontend/src/components/routes/organizer/Reports/CheckInSummaryReport/index.tsx@@ -1,6 +1,6 @@import {Link, useParams} from "react-router";import {useGetOrganizer} from "../../../../../queries/useGetOrganizer.ts";-import {formatDate} from "../../../../../utilites/dates.ts";+import {formatDateWithLocale} from "../../../../../utilites/dates.ts";import OrganizerReportTable from "../../../../common/OrganizerReportTable";import {t} from "@lingui/macro";@@ -28,7 +28,7 @@ const CheckInSummaryReport = () => {key: 'start_date' as const,label: t`Event Date`,sortable: true,- render: (value: string) => value ? formatDate(value, 'MMM D, YYYY', organizer?.timezone) : '-'+ render: (value: string) => value ? formatDateWithLocale(value, 'shortDate', organizer?.timezone || 'UTC') : '-'},{key: 'total_attendees' as const,diff --git a/frontend/src/components/routes/organizer/Reports/EventsPerformanceReport/index.tsx b/frontend/src/components/routes/organizer/Reports/EventsPerformanceReport/index.tsxindex ecce2b6d6..4229ce47d 100644--- a/frontend/src/components/routes/organizer/Reports/EventsPerformanceReport/index.tsx+++ b/frontend/src/components/routes/organizer/Reports/EventsPerformanceReport/index.tsx@@ -2,7 +2,7 @@ import {Link, useParams} from "react-router";import {useGetOrganizer} from "../../../../../queries/useGetOrganizer.ts";import {useGetOrganizerStats} from "../../../../../queries/useGetOrganizerStats.ts";import {formatCurrency} from "../../../../../utilites/currency.ts";-import {formatDate} from "../../../../../utilites/dates.ts";+import {formatDateWithLocale} from "../../../../../utilites/dates.ts";import OrganizerReportTable from "../../../../common/OrganizerReportTable";import {t} from "@lingui/macro";import {Badge} from "@mantine/core";@@ -55,7 +55,7 @@ const EventsPerformanceReport = () => {key: 'start_date' as const,label: t`Date`,sortable: true,- render: (value: string) => value ? formatDate(value, 'MMM D, YYYY', organizer?.timezone) : '-'+ render: (value: string) => value ? formatDateWithLocale(value, 'shortDate', organizer?.timezone || 'UTC') : '-'},{key: 'event_state' as const,diff --git a/frontend/src/components/routes/organizer/Reports/RevenueSummaryReport/index.tsx b/frontend/src/components/routes/organizer/Reports/RevenueSummaryReport/index.tsxindex 59f1f9183..f66285b82 100644--- a/frontend/src/components/routes/organizer/Reports/RevenueSummaryReport/index.tsx+++ b/frontend/src/components/routes/organizer/Reports/RevenueSummaryReport/index.tsx@@ -2,7 +2,7 @@ import {useParams} from "react-router";import {useGetOrganizer} from "../../../../../queries/useGetOrganizer.ts";import {useGetOrganizerStats} from "../../../../../queries/useGetOrganizerStats.ts";import {formatCurrency} from "../../../../../utilites/currency.ts";-import {formatDate} from "../../../../../utilites/dates.ts";+import {formatDateWithLocale} from "../../../../../utilites/dates.ts";import OrganizerReportTable from "../../../../common/OrganizerReportTable";import {t} from "@lingui/macro";@@ -23,7 +23,7 @@ const RevenueSummaryReport = () => {key: 'date' as const,label: t`Date`,sortable: true,- render: (value: string) => formatDate(value, 'MMM D, YYYY', organizer?.timezone)+ render: (value: string) => formatDateWithLocale(value, 'shortDate', organizer?.timezone || 'UTC')},{key: 'gross_sales' as const,diff --git a/frontend/src/components/routes/profile/ManageProfile/index.tsx b/frontend/src/components/routes/profile/ManageProfile/index.tsxindex b1c2457a6..a12c53e1e 100644--- a/frontend/src/components/routes/profile/ManageProfile/index.tsx+++ b/frontend/src/components/routes/profile/ManageProfile/index.tsx@@ -1,7 +1,7 @@import {Card} from "../../../common/Card";import {useForm, UseFormReturnType} from "@mantine/form";import {useGetMe} from "../../../../queries/useGetMe.ts";-import {Alert, Button, PasswordInput, Select, Tabs, TextInput} from "@mantine/core";+import {Alert, Button, NativeSelect, PasswordInput, Select, Tabs, TextInput} from "@mantine/core";import classes from "./ManageProfile.module.scss";import {useEffect, useState} from "react";import {IconInfoCircle, IconPassword, IconUser} from "@tabler/icons-react";@@ -13,7 +13,12 @@ import {useCancelEmailChange} from "../../../../mutations/useCancelEmailChange.timport {useFormErrorResponseHandler} from "../../../../hooks/useFormErrorResponseHandler.tsx";import {t, Trans} from "@lingui/macro";import {useResendEmailConfirmation} from "../../../../mutations/useResendEmailConfirmation.ts";-import {getLocaleName, localeToFlagEmojiMap, localeToNameMap, SupportedLocales} from "../../../../locales.ts";+import {localeToFlagEmojiMap, localeToNameMap, SupportedLocales} from "../../../../locales.ts";++const localeSelectData = Object.keys(localeToNameMap).map(locale => ({+ value: locale,+ label: `${localeToFlagEmojiMap[locale as SupportedLocales]} ${localeToNameMap[locale as SupportedLocales]}`,+}));export const ManageProfile = () => {const {data: me, isFetching} = useGetMe();@@ -162,15 +167,12 @@ export const ManageProfile = () => {placeholder={t`UTC`}/>- <Select+ <NativeSelectrequired- data={Object.keys(localeToNameMap).map(locale => ({- value: locale,- label: localeToFlagEmojiMap[locale as SupportedLocales] + ' ' + getLocaleName(locale as SupportedLocales),- }))}- {...profileForm.getInputProps('locale')}+ data={localeSelectData}+ value={profileForm.values.locale || ''}+ onChange={(e) => profileForm.setFieldValue('locale', e.target.value)}label={t`Language`}- placeholder={t`English`}/><Button fullWidth loading={mutation.isPending}diff --git a/frontend/src/locales.ts b/frontend/src/locales.tsindex 1ec9a5c78..df05aa838 100644--- a/frontend/src/locales.ts+++ b/frontend/src/locales.ts@@ -1,5 +1,4 @@import {i18n} from "@lingui/core";-import {t} from "@lingui/macro";export type SupportedLocales ="en"@@ -51,7 +50,7 @@ export const localeToNameMap: Record<SupportedLocales, string> = {};export const getLocaleName = (locale: SupportedLocales) => {- return t`${localeToNameMap[locale]}`+ return localeToNameMap[locale];}export const getClientLocale = () => {diff --git a/frontend/src/utilites/dateLocales.ts b/frontend/src/utilites/dateLocales.tsnew file mode 100644index 000000000..702870767--- /dev/null+++ b/frontend/src/utilites/dateLocales.ts@@ -0,0 +1,180 @@+/**+ * Day.js locale configuration for internationalized date formatting+ */++import { SupportedLocales } from '../locales.ts';++// Import Day.js locales+import 'dayjs/locale/en';+import 'dayjs/locale/de';+import 'dayjs/locale/fr';+import 'dayjs/locale/it';+import 'dayjs/locale/nl';+import 'dayjs/locale/pt';+import 'dayjs/locale/es';+import 'dayjs/locale/zh-cn';+import 'dayjs/locale/pt-br';+import 'dayjs/locale/vi';+import 'dayjs/locale/zh-hk';+import 'dayjs/locale/tr';+import 'dayjs/locale/hu';++/**+ * Locale-specific date formats following cultural conventions+ */+export const localeFormats: Record<SupportedLocales, {+ fullDateTime: string;+ shortDateTime: string;+ shortDate: string;+ chartDate: string;+ monthShort: string;+ dayOfMonth: string;+ dayName: string;+ timeOnly: string;+ timezone: string;+}> = {+ 'en': {+ fullDateTime: 'ddd, MMM D, YYYY h:mm A',+ shortDateTime: 'MMM D, YYYY h:mma',+ shortDate: 'MMM D, YYYY',+ chartDate: 'MMM D',+ monthShort: 'MMM',+ dayOfMonth: 'D',+ dayName: 'dddd, MMMM D',+ timeOnly: 'h:mm A',+ timezone: 'z'+ },+ 'de': {+ fullDateTime: 'ddd, D. MMM YYYY HH:mm',+ shortDateTime: 'D. MMM YYYY HH:mm',+ shortDate: 'D. MMM YYYY',+ chartDate: 'D. MMM',+ monthShort: 'MMM',+ dayOfMonth: 'D',+ dayName: 'dddd, D. MMMM',+ timeOnly: 'HH:mm',+ timezone: 'z'+ },+ 'fr': {+ fullDateTime: 'ddd D MMM YYYY HH:mm',+ shortDateTime: 'D MMM YYYY HH:mm',+ shortDate: 'D MMM YYYY',+ chartDate: 'D MMM',+ monthShort: 'MMM',+ dayOfMonth: 'D',+ dayName: 'dddd D MMMM',+ timeOnly: 'HH:mm',+ timezone: 'z'+ },+ 'it': {+ fullDateTime: 'ddd D MMM YYYY HH:mm',+ shortDateTime: 'D MMM YYYY HH:mm',+ shortDate: 'D MMM YYYY',+ chartDate: 'D MMM',+ monthShort: 'MMM',+ dayOfMonth: 'D',+ dayName: 'dddd D MMMM',+ timeOnly: 'HH:mm',+ timezone: 'z'+ },+ 'nl': {+ fullDateTime: 'ddd D MMM YYYY HH:mm',+ shortDateTime: 'D MMM YYYY HH:mm',+ shortDate: 'D MMM YYYY',+ chartDate: 'D MMM',+ monthShort: 'MMM',+ dayOfMonth: 'D',+ dayName: 'dddd D MMMM',+ timeOnly: 'HH:mm',+ timezone: 'z'+ },+ 'pt': {+ fullDateTime: 'ddd, D [de] MMM [de] YYYY HH:mm',+ shortDateTime: 'D [de] MMM [de] YYYY HH:mm',+ shortDate: 'D [de] MMM [de] YYYY',+ chartDate: 'D [de] MMM',+ monthShort: 'MMM',+ dayOfMonth: 'D',+ dayName: 'dddd, D [de] MMMM',+ timeOnly: 'HH:mm',+ timezone: 'z'+ },+ 'es': {+ fullDateTime: 'ddd, D [de] MMM [de] YYYY HH:mm',+ shortDateTime: 'D [de] MMM [de] YYYY HH:mm',+ shortDate: 'D [de] MMM [de] YYYY',+ chartDate: 'D [de] MMM',+ monthShort: 'MMM',+ dayOfMonth: 'D',+ dayName: 'dddd, D [de] MMMM',+ timeOnly: 'HH:mm',+ timezone: 'z'+ },+ 'zh-cn': {+ fullDateTime: 'YYYY年M月D日 ddd HH:mm',+ shortDateTime: 'YYYY年M月D日 HH:mm',+ shortDate: 'YYYY年M月D日',+ chartDate: 'M月D日',+ monthShort: 'M月',+ dayOfMonth: 'D日',+ dayName: 'M月D日 dddd',+ timeOnly: 'HH:mm',+ timezone: 'z'+ },+ 'pt-br': {+ fullDateTime: 'ddd, D [de] MMM [de] YYYY HH:mm',+ shortDateTime: 'D [de] MMM [de] YYYY HH:mm',+ shortDate: 'D [de] MMM [de] YYYY',+ chartDate: 'D [de] MMM',+ monthShort: 'MMM',+ dayOfMonth: 'D',+ dayName: 'dddd, D [de] MMMM',+ timeOnly: 'HH:mm',+ timezone: 'z'+ },+ 'vi': {+ fullDateTime: 'ddd, [ngày] D [tháng] M [năm] YYYY HH:mm',+ shortDateTime: '[ngày] D [tháng] M [năm] YYYY HH:mm',+ shortDate: 'D [tháng] M, YYYY',+ chartDate: 'D [tháng] M',+ monthShort: '[Th]M',+ dayOfMonth: 'D',+ dayName: '[ngày] D [tháng] M',+ timeOnly: 'HH:mm',+ timezone: 'z'+ },+ 'zh-hk': {+ fullDateTime: 'YYYY年M月D日 ddd HH:mm',+ shortDateTime: 'YYYY年M月D日 HH:mm',+ shortDate: 'YYYY年M月D日',+ chartDate: 'M月D日',+ monthShort: 'M月',+ dayOfMonth: 'D日',+ dayName: 'M月D日 dddd',+ timeOnly: 'HH:mm',+ timezone: 'z'+ },+ 'tr': {+ fullDateTime: 'ddd, D MMM YYYY HH:mm',+ shortDateTime: 'D MMM YYYY HH:mm',+ shortDate: 'D MMM YYYY',+ chartDate: 'D MMM',+ monthShort: 'MMM',+ dayOfMonth: 'D',+ dayName: 'dddd, D MMMM',+ timeOnly: 'HH:mm',+ timezone: 'z'+ },+ 'hu': {+ fullDateTime: 'YYYY. MMM D., ddd HH:mm',+ shortDateTime: 'YYYY. MMM D. HH:mm',+ shortDate: 'YYYY. MMM D.',+ chartDate: 'MMM D.',+ monthShort: 'MMM',+ dayOfMonth: 'D.',+ dayName: 'dddd, MMMM D.',+ timeOnly: 'HH:mm',+ timezone: 'z'+ },+};+diff --git a/frontend/src/utilites/dates.ts b/frontend/src/utilites/dates.tsindex 1952e9f91..1f1c7c039 100644--- a/frontend/src/utilites/dates.ts+++ b/frontend/src/utilites/dates.ts@@ -8,22 +8,76 @@ import relativeTime from "dayjs/plugin/relativeTime";import utc from 'dayjs/plugin/utc';import timezone from 'dayjs/plugin/timezone';import advanced from 'dayjs/plugin/advancedFormat';-import {isSsr} from "./helpers.ts";+import { isSsr } from "./helpers.ts";+import { getClientLocale, SupportedLocales } from "../locales.ts";+import { localeFormats } from "./dateLocales.ts";dayjs.extend(utc);dayjs.extend(relativeTime);dayjs.extend(timezone);dayjs.extend(advanced)-export const prettyDate = (date: string, tz: string, showTimezoneOffset: boolean = false): string => {- // eslint-disable-next-line lingui/no-unlocalized-strings- return dayjs.utc(date).tz(tz).format('MMM D, YYYY h:mma' + (showTimezoneOffset ? ' (z)' : ''));-};-export const formatDate = (date: string, format: string, tz: string): string => {return dayjs.utc(date).tz(tz).format(format);};+export type DateFormatType = 'fullDateTime' | 'shortDateTime' | 'shortDate' | 'chartDate' | 'monthShort' | 'dayOfMonth' | 'dayName' | 'timeOnly' | 'timezone';++/**+ * Safely get a supported locale, falling back to 'en' if not supported.+ */+const getSafeLocale = (locale?: string): SupportedLocales => {+ if (locale && locale in localeFormats) {+ return locale as SupportedLocales;+ }+ return 'en';+};++/**+ * Format date with locale-specific formatting.+ * Uses locale() method on the dayjs instance to avoid global state mutation.+ */+export const formatDateWithLocale = (+ date: string,+ formatType: DateFormatType,+ tz: string,+ locale?: SupportedLocales | string+): string => {+ const resolvedLocale = locale || getClientLocale();+ const safeLocale = getSafeLocale(resolvedLocale);+ const format = localeFormats[safeLocale][formatType];++ return dayjs.utc(date).tz(tz).locale(safeLocale).format(format);+};++/**+ * Format date with user's preferred locale (from user settings or browser).+ * Priority: user settings > browser locale > English fallback.+ */+export const formatDateForUser = (+ date: string,+ formatType: DateFormatType,+ tz: string,+ userLocaleFromSettings?: string+): string => {+ return formatDateWithLocale(date, formatType, tz, userLocaleFromSettings);+};++/**+ * Format date in a short, readable format with optional timezone.+ * Uses locale-aware formatting.+ */+export const prettyDate = (date: string, tz: string, showTimezoneOffset: boolean = false, locale?: string): string => {+ const formatted = formatDateWithLocale(date, 'shortDateTime', tz, locale);++ if (showTimezoneOffset) {+ const tzAbbr = formatDateWithLocale(date, 'timezone', tz, locale);+ return `${formatted} (${tzAbbr})`;+ }++ return formatted;+};+/*** We don't explicitly convert to the event timezone here as we want to* display the 'ago' time in the user's timezone.@@ -45,17 +99,18 @@ export const utcToTz = (date: undefined | string | Date, tz: string): string | u};/**- * Converts a datetime to the user's browser timezone, with a fallback timezone for SSR.- *- * @param date string- * @param fallbackTz string+ * Converts a datetime to the user's browser timezone with locale-aware formatting.+ * Falls back to provided timezone for SSR.*/-export const dateToBrowserTz = (date: string, fallbackTz: string): string => {+export const dateToBrowserTz = (date: string, fallbackTz: string, locale?: string): string => {const userTimezone = !isSsr()? Intl.DateTimeFormat().resolvedOptions().timeZone: fallbackTz;- return dayjs.utc(date).tz(userTimezone).format('MMM D, YYYY h:mma z');+ const formatted = formatDateWithLocale(date, 'shortDateTime', userTimezone, locale);+ const tzAbbr = formatDateWithLocale(date, 'timezone', userTimezone, locale);++ return `${formatted} ${tzAbbr}`;};export const isDateInFuture = (date: string): boolean => {