From bc0e54fea8d9c3b4c1498ed5f7f597d8ea78cd40 Mon Sep 17 00:00:00 2001 From: Bobban Rydh Date: Tue, 15 Sep 2026 22:35:05 +0200 Subject: [PATCH] Respect the 12h/24h setting in cron schedule descriptions too The Date & Time setting drove formatDateTime() everywhere, but the human-readable cron description ("At 08:30 AM every day") came from cronstrue, a separate library with its own independent AM/PM default that the setting never touched. Pass its use24HourTimeFormat option from the same shared setting so "Schedule" columns match the rest of the app. Added utils/date.ts's is24HourFormat() getter for this, since formatDateTime() itself doesn't apply here (cronstrue does its own cron-to-English rendering, not just time formatting). Co-Authored-By: Claude Sonnet 5 --- web/src/components/ServerTaskTable.tsx | 4 ++-- web/src/utils/date.ts | 5 +++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/web/src/components/ServerTaskTable.tsx b/web/src/components/ServerTaskTable.tsx index bdcc63c..cd31f59 100644 --- a/web/src/components/ServerTaskTable.tsx +++ b/web/src/components/ServerTaskTable.tsx @@ -1,7 +1,7 @@ import cronstrue from "cronstrue"; import { CronExpressionParser } from "cron-parser"; import type { TaskRecord } from "../api/client"; -import { formatDateTime } from "../utils/date"; +import { formatDateTime, is24HourFormat } from "../utils/date"; export const SCHEDULE_TYPE_LABELS: Record = { cron: "Cron jobs", @@ -17,7 +17,7 @@ function describeSchedule(task: TaskRecord): string { if (!task.scheduleExpression) return "—"; if (task.scheduleType === "cron") { try { - return cronstrue.toString(task.scheduleExpression, { verbose: false }); + return cronstrue.toString(task.scheduleExpression, { verbose: false, use24HourTimeFormat: is24HourFormat() }); } catch { return task.scheduleExpression; } diff --git a/web/src/utils/date.ts b/web/src/utils/date.ts index f5c7b6b..ddf27e3 100644 --- a/web/src/utils/date.ts +++ b/web/src/utils/date.ts @@ -12,6 +12,11 @@ export function setDateTimeSettings(settings: DateTimeSettings): void { current = settings; } +/** Current 12h/24h preference, for formatters outside this file (e.g. cronstrue's use24HourTimeFormat option). */ +export function is24HourFormat(): boolean { + return current.timeFormat === "24h"; +} + function pad(n: number): string { return String(n).padStart(2, "0"); }