[#31]added two function to setup data to be sent and put function

This commit is contained in:
Camille Moussu
2025-07-22 09:50:02 +02:00
parent fd059954f4
commit b1ceebfc7d
12 changed files with 2906 additions and 48 deletions
File diff suppressed because it is too large Load Diff
+38
View File
@@ -0,0 +1,38 @@
// timezone.ts
// Ensure ICAL is imported before using this module.
import ICAL from "ical.js";
// TIMEZONES data must be imported or defined separately.
import { TIMEZONES } from "./timezone-data";
// Core timezone registration functionality
export function registerTimezones() {
for (const [key, data] of Object.entries(TIMEZONES.zones)) {
ICAL.TimezoneService.register(key, buildTimezone(key, data.ics));
}
for (const [key, data] of Object.entries(TIMEZONES.aliases)) {
ICAL.TimezoneService.register(key, findTimezone(data.aliasTo));
}
}
function buildTimezone(tzid: string, ics: string): any {
return (
ICAL.TimezoneService.get(tzid) ||
new ICAL.Timezone(new ICAL.Component(ICAL.parse(ics)))
);
}
function findTimezone(tzid: string): any {
if (TIMEZONES.zones[tzid]) {
return buildTimezone(tzid, TIMEZONES.zones[tzid].ics);
}
const alias = TIMEZONES.aliases[tzid];
if (alias && alias.aliasTo) {
return findTimezone(alias.aliasTo);
}
throw new Error(`Unknown timezone alias: ${tzid}`);
}