forked from GitHubMirrors/silverbullet-icalendar
Bump version to 0.2.10 and add explicit date localization with logs
All checks were successful
Build SilverBullet Plug / build (push) Successful in 20s
All checks were successful
Build SilverBullet Plug / build (push) Successful in 20s
This commit is contained in:
2
PLUG.md
2
PLUG.md
@@ -1,6 +1,6 @@
|
|||||||
---
|
---
|
||||||
name: Library/sstent/icalendar/PLUG
|
name: Library/sstent/icalendar/PLUG
|
||||||
version: 0.2.9
|
version: 0.2.10
|
||||||
tags: meta/library
|
tags: meta/library
|
||||||
files:
|
files:
|
||||||
- icalendar.plug.js
|
- icalendar.plug.js
|
||||||
|
|||||||
12
icalendar.ts
12
icalendar.ts
@@ -2,7 +2,7 @@ import { clientStore, config, datastore, editor, index } from "@silverbulletmd/s
|
|||||||
import { localDateString } from "@silverbulletmd/silverbullet/lib/dates";
|
import { localDateString } from "@silverbulletmd/silverbullet/lib/dates";
|
||||||
import { convertIcsCalendar, type IcsCalendar, type IcsEvent, type IcsDateObjects } from "ts-ics";
|
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 CACHE_KEY = "icalendar:lastSync";
|
||||||
const DEFAULT_CACHE_DURATION_SECONDS = 21600; // 6 hours
|
const DEFAULT_CACHE_DURATION_SECONDS = 21600; // 6 hours
|
||||||
|
|
||||||
@@ -85,18 +85,20 @@ function convertDatesToStrings<T>(obj: T, timezones?: any): DateToString<T> {
|
|||||||
|
|
||||||
if (obj instanceof Date) {
|
if (obj instanceof Date) {
|
||||||
const localized = localDateString(obj);
|
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<T>;
|
return localized as DateToString<T>;
|
||||||
}
|
}
|
||||||
if (isIcsDateObjects(obj) && obj.date instanceof Date) {
|
if (isIcsDateObjects(obj) && obj.date instanceof Date) {
|
||||||
const localized = localDateString(obj.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<T>;
|
return localized as DateToString<T>;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (typeof obj === 'string' && /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}/.test(obj)) {
|
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")));
|
const forcedUTC = obj.endsWith("Z") ? obj : obj + "Z";
|
||||||
console.log(`[iCalendar] Localizing ISO String: Raw=${obj} -> PST=${localized}`);
|
const dateObj = new Date(forcedUTC);
|
||||||
|
const localized = localDateString(dateObj);
|
||||||
|
console.log(`[iCalendar] MATCH ISO String: Raw=${obj} -> PST=${localized}`);
|
||||||
return localized as DateToString<T>;
|
return localized as DateToString<T>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user