Skip to content

Commit

Permalink
fix: remove utc from date string in parsing (#31)
Browse files Browse the repository at this point in the history
  • Loading branch information
glitchedmob authored Oct 7, 2024
1 parent 33d6e10 commit 4f50f95
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions frontend/src/data/parseUtcAsCst.ts
Original file line number Diff line number Diff line change
@@ -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);
}

0 comments on commit 4f50f95

Please sign in to comment.