forked from GitHubMirrors/silverbullet-icalendar
Fix: Handle potential Date objects in event start and iterate to 0.3.23
All checks were successful
Build SilverBullet Plug / build (push) Successful in 29s
All checks were successful
Build SilverBullet Plug / build (push) Successful in 29s
This commit is contained in:
11
icalendar.ts
11
icalendar.ts
@@ -1,7 +1,7 @@
|
||||
import { clientStore, config, datastore, editor, index } from "@silverbulletmd/silverbullet/syscalls";
|
||||
import { convertIcsCalendar } from "https://esm.sh/ts-ics@2.4.0";
|
||||
|
||||
const VERSION = "0.3.22";
|
||||
const VERSION = "0.3.23";
|
||||
const CACHE_KEY = "icalendar:lastSync";
|
||||
|
||||
console.log(`[iCalendar] Plug script executing at top level (Version ${VERSION})`);
|
||||
@@ -83,11 +83,14 @@ async function fetchAndParseCalendar(source: any, hourShift = 0): Promise<any[]>
|
||||
}
|
||||
|
||||
let wallTimeStr = "";
|
||||
if (obj.local && typeof obj.local.date === "string") wallTimeStr = obj.local.date;
|
||||
else if (typeof obj.date === "string") wallTimeStr = obj.date;
|
||||
if (obj.local && obj.local.date) {
|
||||
wallTimeStr = typeof obj.local.date === "string" ? obj.local.date : obj.local.date.toISOString?.() || String(obj.local.date);
|
||||
} else if (obj.date) {
|
||||
wallTimeStr = typeof obj.date === "string" ? obj.date : obj.date.toISOString?.() || String(obj.date);
|
||||
}
|
||||
|
||||
if (!wallTimeStr) {
|
||||
console.warn("[iCalendar] Skipping event with no start date string:", icsEvent.summary, "Start object structure:", JSON.stringify(obj));
|
||||
console.warn("[iCalendar] Skipping event with no start date string:", icsEvent.summary, "Start object structure:", JSON.stringify(obj), "typeof date:", typeof obj.date, "typeof local.date:", typeof obj.local?.date);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user