From 14c2807f0ad6f8c49cd309bed4090bd9aba0b77a Mon Sep 17 00:00:00 2001 From: honzup <5564623+honzup@users.noreply.github.com> Date: Thu, 2 Jul 2026 15:16:59 +0200 Subject: [PATCH] feat: add user-selectable regional date format --- components/settings/language-settings.tsx | 21 ++++++-- lib/utils.ts | 65 ++++++++++++++++++----- locales/cs/common.json | 8 +++ locales/da/common.json | 8 +++ locales/de/common.json | 8 +++ locales/en/common.json | 8 +++ locales/es/common.json | 8 +++ locales/fa/common.json | 8 +++ locales/fr/common.json | 8 +++ locales/hu/common.json | 8 +++ locales/it/common.json | 8 +++ locales/ja/common.json | 8 +++ locales/ko/common.json | 8 +++ locales/lv/common.json | 8 +++ locales/nl/common.json | 8 +++ locales/pl/common.json | 8 +++ locales/pt/common.json | 8 +++ locales/ro/common.json | 8 +++ locales/ru/common.json | 8 +++ locales/tr/common.json | 8 +++ locales/uk/common.json | 8 +++ locales/zh/common.json | 8 +++ stores/settings-store.ts | 11 ++++ 23 files changed, 241 insertions(+), 16 deletions(-) diff --git a/components/settings/language-settings.tsx b/components/settings/language-settings.tsx index 1a5cdf9d..d0faacaf 100644 --- a/components/settings/language-settings.tsx +++ b/components/settings/language-settings.tsx @@ -5,7 +5,7 @@ import { useTranslations } from 'next-intl'; import { LanguageSwitcher } from '@/components/ui/language-switcher'; import { useLocaleStore } from '@/stores/locale-store'; import { useSettingsStore } from '@/stores/settings-store'; -import type { DateFormat, TimeFormat, FirstDayOfWeek } from '@/stores/settings-store'; +import type { DateFormat, DateLocale, TimeFormat, FirstDayOfWeek } from '@/stores/settings-store'; import { formatDate } from '@/lib/utils'; import { SettingsSection, SettingItem, Select, RadioGroup } from './settings-section'; @@ -13,7 +13,7 @@ export function LanguageSettings() { const t = useTranslations('settings.language_region'); const tDays = useTranslations('calendar.days'); - const { dateFormat, timeFormat, firstDayOfWeek, updateSetting } = useSettingsStore(); + const { dateFormat, dateLocale, timeFormat, firstDayOfWeek, updateSetting } = useSettingsStore(); // Subscribe to locale changes so the preview re-renders on language switch // (formatDate reads it via getState() and would otherwise stay stale). @@ -23,7 +23,7 @@ export function LanguageSettings() { // Build sample timestamps for each bucket so users see what their pick // will look like in practice. Use offsets relative to "now" so the // bucketing is stable even though the wall-clock keeps moving. - void locale; void dateFormat; void timeFormat; + void locale; void dateFormat; void dateLocale; void timeFormat; const now = new Date(); const today = new Date(now); today.setHours(15, 31, 0, 0); @@ -38,7 +38,7 @@ export function LanguageSettings() { thisWeek: formatDate(thisWeek), older: formatDate(older), }; - }, [locale, dateFormat, timeFormat]); + }, [locale, dateFormat, dateLocale, timeFormat]); return ( @@ -74,6 +74,19 @@ export function LanguageSettings() { + +