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 <noreply@anthropic.com>
This commit is contained in:
@@ -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<string, string> = {
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -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");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user