Skip to content

Commit 3015576

Browse files
committed
feat(board/promoted_attributes): format date & time
1 parent 46c2e16 commit 3015576

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

apps/client/src/widgets/attribute_widgets/PromotedAttributesDisplay.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import "./PromotedAttributesDisplay.css";
44
import { useTriliumEvent } from "../react/hooks";
55
import attributes from "../../services/attributes";
66
import { DefinitionObject } from "../../services/promoted_attribute_definition_parser";
7+
import { formatDateTime } from "../../utils/formatters";
78

89
interface PromotedAttributesDisplayProps {
910
note: FNote;
@@ -57,6 +58,12 @@ function formatLabelValue(attr: AttributeWithDefinitions): string {
5758
} else {
5859
return numberValue.toString();
5960
}
61+
case "date":
62+
case "datetime":
63+
const date = new Date(value);
64+
if (isNaN(date.getTime())) return value;
65+
const timeFormat = attr.def.labelType === "datetime" ? "short" : "none";
66+
return formatDateTime(date, "short", timeFormat);
6067
case "text":
6168
default:
6269
return value;

0 commit comments

Comments
 (0)