mirror of
https://github.com/zadam/trilium.git
synced 2025-11-13 09:59:02 +01:00
feat(board/promoted_attributes): format date & time
This commit is contained in:
parent
46c2e162f0
commit
3015576d7e
@ -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;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user