mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-26 18:42:49 +00:00
feat(reports): carry time of day on report date columns
Eleven report columns bucketed their timestamp to a bare day with to_char, which is wrong for anything a user reads as an event rather than a period: two departures on the same date, or a wagon request fulfilled hours after it was raised, were indistinguishable in the output. The renderer only shows the time when the value actually has one, keyed off the string rather than a per-column flag — a genuine day bucket would otherwise render as 12:00 AM, which reads as data rather than as absence.
This commit is contained in:
@@ -17,10 +17,17 @@ export function formatReportCell(value: unknown, type: ReportColumnType): string
|
||||
case "number":
|
||||
return Number(value).toLocaleString();
|
||||
case "date": {
|
||||
const d = new Date(String(value));
|
||||
return Number.isNaN(d.getTime())
|
||||
? String(value)
|
||||
: d.toLocaleDateString(undefined, { year: "numeric", month: "short", day: "numeric" });
|
||||
const raw = String(value);
|
||||
const d = new Date(raw);
|
||||
if (Number.isNaN(d.getTime())) return raw;
|
||||
// Day-bucket columns carry no time part — don't invent a 12:00 AM for them.
|
||||
const hasTime = /\d:\d/.test(raw);
|
||||
return d.toLocaleString(undefined, {
|
||||
year: "numeric",
|
||||
month: "short",
|
||||
day: "numeric",
|
||||
...(hasTime ? { hour: "2-digit", minute: "2-digit" } : {}),
|
||||
});
|
||||
}
|
||||
default:
|
||||
return String(value);
|
||||
|
||||
Reference in New Issue
Block a user