diff --git a/client/src/components/Dashboard/TimezoneWidget.tsx b/client/src/components/Dashboard/TimezoneWidget.tsx index 087937a..f3b3a8e 100644 --- a/client/src/components/Dashboard/TimezoneWidget.tsx +++ b/client/src/components/Dashboard/TimezoneWidget.tsx @@ -1,6 +1,7 @@ import { useState, useEffect } from 'react' import { Clock, Plus, X } from 'lucide-react' import { useTranslation } from '../../i18n' +import { useSettingsStore } from '../../store/settingsStore' const POPULAR_ZONES = [ { label: 'New York', tz: 'America/New_York' }, @@ -23,9 +24,9 @@ const POPULAR_ZONES = [ { label: 'Cairo', tz: 'Africa/Cairo' }, ] -function getTime(tz, locale) { +function getTime(tz, locale, is12h) { try { - return new Date().toLocaleTimeString(locale, { timeZone: tz, hour: '2-digit', minute: '2-digit' }) + return new Date().toLocaleTimeString(locale, { timeZone: tz, hour: '2-digit', minute: '2-digit', hour12: is12h }) } catch { return '—' } } @@ -42,6 +43,7 @@ function getOffset(tz) { export default function TimezoneWidget() { const { t, locale } = useTranslation() + const is12h = useSettingsStore(s => s.settings.time_format) === '12h' const [zones, setZones] = useState(() => { const saved = localStorage.getItem('dashboard_timezones') return saved ? JSON.parse(saved) : [ @@ -87,7 +89,7 @@ export default function TimezoneWidget() { const removeZone = (tz) => setZones(zones.filter(z => z.tz !== tz)) - const localTime = new Date().toLocaleTimeString(locale, { hour: '2-digit', minute: '2-digit' }) + const localTime = new Date().toLocaleTimeString(locale, { hour: '2-digit', minute: '2-digit', hour12: is12h }) const rawZone = Intl.DateTimeFormat().resolvedOptions().timeZone const localZone = rawZone.split('/').pop().replace(/_/g, ' ') // Show abbreviated timezone name (e.g. CET, CEST, EST) @@ -113,7 +115,7 @@ export default function TimezoneWidget() { {zones.map(z => (
{getTime(z.tz, locale)}
+{getTime(z.tz, locale, is12h)}
{z.label} {getOffset(z.tz)}