From 1daa39b0508dc2e5fb31525ffc5d7dfdb4c57340 Mon Sep 17 00:00:00 2001 From: Levi Zitting Date: Mon, 7 Oct 2024 12:41:07 -0500 Subject: [PATCH] fix: remove utc from date string in parsing --- frontend/src/data/parseUtcAsCst.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/frontend/src/data/parseUtcAsCst.ts b/frontend/src/data/parseUtcAsCst.ts index 822cf81..70a34e4 100644 --- a/frontend/src/data/parseUtcAsCst.ts +++ b/frontend/src/data/parseUtcAsCst.ts @@ -1,10 +1,9 @@ -import { parse } from 'date-fns'; import { CST_TZ } from '@/config'; import { TZDate } from '@date-fns/tz'; // Umbraco doesn't save dates with timezone information so we have to manually fix it export function parseUtcAsCst(dateStr: string): TZDate { - const utcDate = parse(dateStr, "yyyy-MM-dd'T'HH:mm:ss'Z'", new Date()); + const dateStrWithoutZ = dateStr.replace(/Z$/, ''); - return new TZDate(utcDate, CST_TZ); + return new TZDate(dateStrWithoutZ, CST_TZ); }