diff --git a/PLUG.md b/PLUG.md index 52e8814..1177802 100644 --- a/PLUG.md +++ b/PLUG.md @@ -1,6 +1,6 @@ --- name: Library/sstent/icalendar/PLUG -version: 0.2.9 +version: 0.2.10 tags: meta/library files: - icalendar.plug.js diff --git a/icalendar.ts b/icalendar.ts index 294e87f..8f74488 100644 --- a/icalendar.ts +++ b/icalendar.ts @@ -2,7 +2,7 @@ import { clientStore, config, datastore, editor, index } from "@silverbulletmd/s import { localDateString } from "@silverbulletmd/silverbullet/lib/dates"; import { convertIcsCalendar, type IcsCalendar, type IcsEvent, type IcsDateObjects } from "ts-ics"; -const VERSION = "0.2.9"; +const VERSION = "0.2.10"; const CACHE_KEY = "icalendar:lastSync"; const DEFAULT_CACHE_DURATION_SECONDS = 21600; // 6 hours @@ -85,18 +85,20 @@ function convertDatesToStrings(obj: T, timezones?: any): DateToString { if (obj instanceof Date) { const localized = localDateString(obj); - console.log(`[iCalendar] Localizing Date Object: UTC=${obj.toISOString()} -> PST=${localized}`); + console.log(`[iCalendar] MATCH Date Object: ${obj.toISOString()} -> PST=${localized}`); return localized as DateToString; } if (isIcsDateObjects(obj) && obj.date instanceof Date) { const localized = localDateString(obj.date); - console.log(`[iCalendar] Localizing ICS Date Object: UTC=${obj.date.toISOString()} -> PST=${localized} (TZID: ${obj.timezone || "none"})`); + console.log(`[iCalendar] MATCH ICS Date Object: ${obj.date.toISOString()} -> PST=${localized} (TZID: ${obj.timezone || "none"})`); return localized as DateToString; } if (typeof obj === 'string' && /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}/.test(obj)) { - const localized = localDateString(new Date(obj + (obj.endsWith("Z") ? "" : "Z"))); - console.log(`[iCalendar] Localizing ISO String: Raw=${obj} -> PST=${localized}`); + const forcedUTC = obj.endsWith("Z") ? obj : obj + "Z"; + const dateObj = new Date(forcedUTC); + const localized = localDateString(dateObj); + console.log(`[iCalendar] MATCH ISO String: Raw=${obj} -> PST=${localized}`); return localized as DateToString; }