From 54a2adc740ce8deee247f8f6761db46db2ffbc02 Mon Sep 17 00:00:00 2001 From: joffrey-b Date: Sat, 30 May 2026 21:09:26 +0200 Subject: [PATCH 1/2] Add KOITO_DATE_FORMAT and KOITO_CLOCK_FORMAT configuration options --- client/api/api.ts | 2 ++ client/app/components/ActivityGrid.tsx | 5 ++- client/app/components/ListensTable.tsx | 4 +-- client/app/providers/AppProvider.tsx | 8 +++++ client/app/routes/MediaItems/MediaLayout.tsx | 8 ++--- client/app/utils/utils.ts | 31 +++++++++++-------- .../content/docs/reference/configuration.md | 11 +++++++ engine/handlers/server_cfg.go | 8 ++++- internal/cfg/cfg.go | 22 +++++++++++++ internal/cfg/getters.go | 12 +++++++ 10 files changed, 90 insertions(+), 21 deletions(-) diff --git a/client/api/api.ts b/client/api/api.ts index 3bcd31c7..1144c0b5 100644 --- a/client/api/api.ts +++ b/client/api/api.ts @@ -436,6 +436,8 @@ type ApiError = { }; type Config = { default_theme: string; + date_format: string; + clock_format: string; }; type NowPlaying = { currently_playing: boolean; diff --git a/client/app/components/ActivityGrid.tsx b/client/app/components/ActivityGrid.tsx index ae6774f2..326e6eb5 100644 --- a/client/app/components/ActivityGrid.tsx +++ b/client/app/components/ActivityGrid.tsx @@ -1,4 +1,6 @@ import { useQuery } from "@tanstack/react-query"; +import { useAppContext } from "~/providers/AppProvider"; +import { formatDate } from "~/utils/utils"; import Popup from "./Popup"; import { apiFetch, @@ -55,6 +57,7 @@ export default function ActivityGrid({ queryFn: () => getActivity(args), }); + const { dateFormat } = useAppContext(); const width = useWindowWidth(); if (isPending) { @@ -165,7 +168,7 @@ export default function ActivityGrid({ position="top" space={12} extraClasses="left-2" - inner={`${cell.date.toLocaleDateString()} ${ + inner={`${formatDate(cell.date, dateFormat)} ${ cell.listens } plays`} > diff --git a/client/app/components/ListensTable.tsx b/client/app/components/ListensTable.tsx index d45457f5..fcc4b755 100644 --- a/client/app/components/ListensTable.tsx +++ b/client/app/components/ListensTable.tsx @@ -21,7 +21,7 @@ export default function ListensTable({ hideArtists, onDelete, }: ListensTableProps) { - const { user } = useAppContext(); + const { user, dateFormat, clockFormat } = useAppContext(); const imgColSizeClasses = "py-3 min-w-8 sm:min-w-11"; const imgSize = 32; const timeColClasses = "text-(--color-fg-tertiary) pr-2 sm:pr-4 sm:text-sm"; @@ -99,7 +99,7 @@ export default function ListensTable({ className={`text-end whitespace-nowrap ${timeColClasses}`} title={new Date(item.time).toString()} > - {timeSince(new Date(item.time))} + {timeSince(new Date(item.time), dateFormat, clockFormat)}