From d1eb4dae1c74802e88283b763145ff54b22543e1 Mon Sep 17 00:00:00 2001 From: Jonathon Mascorella Date: Thu, 23 Feb 2023 21:01:30 +1100 Subject: [PATCH] Included timezone shift Includes an adjustment to take into account the potential for a timezone to be included in the DTSTART or DTEND datetime and calculates to remove the timezone, apply as GMT and allow the local browser to render appropriately for the local timezone --- index.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/index.js b/index.js index ccbe1b5..f42b644 100644 --- a/index.js +++ b/index.js @@ -61,7 +61,14 @@ module.exports.parseString = function(st, max) { events[event_count][k].value = getDate(params["VALUE"], value); } else { if(params["TZID"] !== undefined) { + //Allow to parse as per GMT events[event_count][k].value = getDate(undefined, value.concat('Z')); + //If a locale exists, strip preceeding / + if(params["TZID"].search(/\//) != -1){ + params["TZID"] = params["TZID"].slice(1); + } + //Pass to toLocaleString to reduce to GMT based on timezone + events[event_count][k].value.toLocaleString(undefined, {timeZone: params["TZID"]}); } else { events[event_count][k].value = getDate(undefined, value); }