fix: don't try to format invalid dates as ISO

This commit is contained in:
kolaente 2022-01-18 21:28:01 +01:00 committed by Gitea
parent 2e77df2db2
commit 50c3bcd793
2 changed files with 6 additions and 3 deletions

View file

@ -1,5 +1,5 @@
import {createDateFromString} from '@/helpers/time/createDateFromString' import {createDateFromString} from '@/helpers/time/createDateFromString'
import {format, formatDistanceToNow} from 'date-fns' import {format, formatDistanceToNow, formatISO as formatISOfns} from 'date-fns'
import {enGB, de, fr, ru} from 'date-fns/locale' import {enGB, de, fr, ru} from 'date-fns/locale'
import {i18n} from '@/i18n' import {i18n} from '@/i18n'
@ -44,3 +44,7 @@ export const formatDateSince = (date) => {
addSuffix: true, addSuffix: true,
}) })
} }
export function formatISO(date) {
return date ? formatISOfns(date) : ''
}

View file

@ -18,8 +18,7 @@ declare global {
} }
} }
import {formatDate, formatDateShort, formatDateLong, formatDateSince} from '@/helpers/time/formatDate' import {formatDate, formatDateShort, formatDateLong, formatDateSince, formatISO} from '@/helpers/time/formatDate'
import {formatISO} from 'date-fns'
// @ts-ignore // @ts-ignore
import {VERSION} from './version.json' import {VERSION} from './version.json'