From 81a293e7ddacad967fabc0181f093777ff7350be Mon Sep 17 00:00:00 2001 From: Biologisten Date: Thu, 21 Aug 2025 02:31:08 +0200 Subject: [PATCH] Added date and time formats to settings --- frontend/src/pages/Guide.jsx | 17 +++++++++----- frontend/src/pages/Settings.jsx | 39 ++++++++++++++++++++++++++++++++- frontend/src/pages/Stats.jsx | 7 ++++-- 3 files changed, 55 insertions(+), 8 deletions(-) diff --git a/frontend/src/pages/Guide.jsx b/frontend/src/pages/Guide.jsx index cfc1d298..91e558ee 100644 --- a/frontend/src/pages/Guide.jsx +++ b/frontend/src/pages/Guide.jsx @@ -24,6 +24,7 @@ import { import { Search, X, Clock, Video, Calendar, Play } from 'lucide-react'; import './guide.css'; import useEPGsStore from '../store/epgs'; +import useLocalStorage from '../hooks/useLocalStorage'; /** Layout constants */ const CHANNEL_WIDTH = 120; // Width of the channel/logo column @@ -196,7 +197,7 @@ export default function TVChannelGuide({ startDate, endDate }) { return time.format('dddd'); } else { // Beyond a week, show month and day - return time.format('MMM D'); + return time.format(dateFormat); } }; @@ -636,7 +637,7 @@ export default function TVChannelGuide({ startDate, endDate }) { overflow: 'hidden', }} > - {programStart.format('h:mma')} - {programEnd.format('h:mma')} + {programStart.format(timeFormat)} - {programEnd.format(timeFormat)} {/* Description is always shown but expands when row is expanded */} {program.description && ( @@ -766,6 +767,12 @@ export default function TVChannelGuide({ startDate, endDate }) { setSelectedProfileId(value || 'all'); }; + // Handle date-time formats + const [timeFormatSetting] = useLocalStorage('time-format', '12h'); + const [dateFormatSetting] = useLocalStorage('date-format', 'mdy'); + const timeFormat = timeFormatSetting === '12h' ? "h:mm A" : "HH:mm"; + const dateFormat = dateFormatSetting === 'mdy' ? "MMMM D" : "D MMMM"; + return ( - {now.format('dddd, MMMM D, YYYY • h:mm A')} + {now.format(`dddd, ${dateFormat}, YYYY • ${timeFormat}`)} - {time.format('h:mm')} + {time.format(timeFormat)} - {time.format('A')} + {/*time.format('A')*/} diff --git a/frontend/src/pages/Settings.jsx b/frontend/src/pages/Settings.jsx index 7533637b..c940601e 100644 --- a/frontend/src/pages/Settings.jsx +++ b/frontend/src/pages/Settings.jsx @@ -59,6 +59,8 @@ const SettingsPage = () => { // UI / local storage settings const [tableSize, setTableSize] = useLocalStorage('table-size', 'default'); + const [timeFormat, setTimeFormat] = useLocalStorage('time-format', '12h'); + const [dateFormat, setDateFormat] = useLocalStorage('date-format', 'mdy'); const regionChoices = REGION_CHOICES; @@ -265,6 +267,12 @@ const SettingsPage = () => { case 'table-size': setTableSize(value); break; + case 'time-format': + setTimeFormat(value); + break; + case 'date-format': + setDateFormat(value); + break; } }; @@ -360,6 +368,36 @@ const SettingsPage = () => { }, ]} /> + onUISettingsChange('date-format', val)} + data={[ + { + value: 'mdy', + label: 'MM/DD/YYYY', + }, + { + value: 'dmy', + label: 'DD/MM/YYYY', + }, + ]} + /> @@ -390,7 +428,6 @@ const SettingsPage = () => { label: option.name, }))} /> -