diff --git a/src/helpers/parseDate/index.tsx b/src/helpers/parseDate/index.tsx index e2e2f72c..37b31c28 100644 --- a/src/helpers/parseDate/index.tsx +++ b/src/helpers/parseDate/index.tsx @@ -1,9 +1,21 @@ +import endsWith from 'lodash/endsWith' import parse from 'date-fns/parse' -export const parseDate = (dateString: string, format = 'yyyy-MM-dd HH:mm:ss') => ( - parse( +const dateFormats = { + withTimezone: 'yyyy-MM-dd HH:mm:ssx', + withoutTimezone: 'yyyy-MM-dd HH:mm:ss', +} + +export const parseDate = ( + dateString: string, + format?: string, +) => { + const defaultFormat = endsWith(dateString, 'Z') + ? dateFormats.withTimezone + : dateFormats.withoutTimezone + return parse( dateString, - format, + format ?? defaultFormat, new Date(), ) -) +}