Skip to content

Commit

Permalink
Fix #954; Linked page date properties not formatting correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
mgmeyers committed May 22, 2024
1 parent 190e0b7 commit d018888
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/components/Item/MetadataTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,12 @@ export function getLinkFromObj(v: any, view: KanbanView) {
}

function getDate(v: any) {
if (typeof v === 'string' && /\d{4}-\d{2}-\d{2}/.test(v)) return moment(v);
if (typeof v === 'string' && /^\d{4}-\d{2}-\d{2}/.test(v)) {
const d = moment(v);
if (d.isValid()) {
return d;
}
}
if (moment.isMoment(v)) return v;
if (v.ts) return moment(v.ts);
if (v instanceof Date) return moment(v);
Expand All @@ -122,10 +127,10 @@ function getDate(v: any) {

export function anyToString(v: any, stateManager: StateManager): string {
if (v.value) v = v.value;
if (typeof v === 'string') return v;
if (v instanceof TFile) return v.path;
const date = getDate(v);
if (date) return getDateFromObj(date, stateManager);
if (typeof v === 'string') return v;
if (v instanceof TFile) return v.path;
if (typeof v === 'object' && v.path) return v.display || v.path;
if (Array.isArray(v)) {
return v.map((v2) => anyToString(v2, stateManager)).join(' ');
Expand Down

0 comments on commit d018888

Please sign in to comment.