Skip to content

Build your personal knowledge base with Trilium Notes

feat(board/promoted_attributes): format date & time

Elian Doran3015576d7e2b
diff --git a/apps/client/src/widgets/attribute_widgets/PromotedAttributesDisplay.tsx b/apps/client/src/widgets/attribute_widgets/PromotedAttributesDisplay.tsx
index 761a0bb3b3..432ec4899d 100644
--- a/apps/client/src/widgets/attribute_widgets/PromotedAttributesDisplay.tsx
+++ b/apps/client/src/widgets/attribute_widgets/PromotedAttributesDisplay.tsx
@@ -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;