feat(board/promoted_attributes): format date & time

This commit is contained in:
Elian Doran 2025-11-12 20:34:48 +02:00
parent 46c2e162f0
commit 3015576d7e
No known key found for this signature in database

View File

@ -4,6 +4,7 @@ import "./PromotedAttributesDisplay.css";
import { useTriliumEvent } from "../react/hooks";
import attributes from "../../services/attributes";
import { DefinitionObject } from "../../services/promoted_attribute_definition_parser";
import { formatDateTime } from "../../utils/formatters";
interface PromotedAttributesDisplayProps {
note: FNote;
@ -57,6 +58,12 @@ function formatLabelValue(attr: AttributeWithDefinitions): string {
} else {
return numberValue.toString();
}
case "date":
case "datetime":
const date = new Date(value);
if (isNaN(date.getTime())) return value;
const timeFormat = attr.def.labelType === "datetime" ? "short" : "none";
return formatDateTime(date, "short", timeFormat);
case "text":
default:
return value;