Skip to content

Commit 0087484

Browse files
committed
feat(board/promoted_attributes): format time
1 parent d79a23b commit 0087484

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

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

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,15 @@ function formatLabelValue(attr: AttributeWithDefinitions): ComponentChildren {
6161
}
6262
return <><strong>{attr.friendlyName}:</strong> {formattedValue}</>;
6363
case "date":
64-
case "datetime":
64+
case "datetime": {
6565
const date = new Date(value);
66-
if (isNaN(date.getTime())) return value;
67-
const timeFormat = attr.def.labelType === "datetime" ? "short" : "none";
66+
const timeFormat = attr.def.labelType !== "date" ? "short" : "none";
6867
return <><strong>{attr.friendlyName}:</strong> {formatDateTime(date, "short", timeFormat)}</>;
68+
}
69+
case "time": {
70+
const date = new Date(`1970-01-01T${value}Z`);
71+
return <><strong>{attr.friendlyName}:</strong> {formatDateTime(date, "none", "short")}</>;
72+
}
6973
case "boolean":
7074
return <><Icon icon={value === "true" ? "bx bx-check-square" : "bx bx-square"} /> <strong>{attr.friendlyName}</strong></>;
7175
case "text":
@@ -81,7 +85,7 @@ function getAttributesWithDefinitions(note: FNote, attributesToIgnore: string[]
8185
const def = attr.getDefinition();
8286
const [ type, name ] = attr.name.split(":", 2);
8387
const value = note.getLabelValue(name);
84-
const friendlyName = def?.promotedAlias ?? name;
88+
const friendlyName = def?.promotedAlias || name;
8589
if (!value) continue;
8690
if (attributesToIgnore.includes(name)) continue;
8791

0 commit comments

Comments
 (0)