From 5061628b608c3d8197272f7c622c3a4e957170e0 Mon Sep 17 00:00:00 2001 From: Blake Mason Date: Mon, 11 Mar 2024 10:25:18 -0700 Subject: [PATCH] [B] Event times strip timezone offsets --- lib/utils.js | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/lib/utils.js b/lib/utils.js index a488ad24..50c05c16 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -170,6 +170,11 @@ export const usePathData = () => { return { asPath, pathname, query }; }; +function dateWoTimezone(iso) { + // attuned to the iso-ish php dateformat from Craft + return new Date(iso.slice(0, -6)); +} + export const useDateString = (date, isShort = false) => { const localeInfo = useGlobalData("localeInfo"); const locale = localeInfo.language || "en-US"; @@ -184,15 +189,11 @@ export const useDateString = (date, isShort = false) => { return dateString; }; -export const useTimeString = (time) => { +export const useTimeString = (iso) => { const localeInfo = useGlobalData("localeInfo"); const locale = localeInfo.language || "en-US"; - - if (!time) return undefined; - - const newTime = new Date(time).toLocaleTimeString(locale); - - return newTime; + if (!iso) return undefined; + return dateWoTimezone(iso).toLocaleTimeString(locale); }; export const useTimeZone = (timezone) => {