diff --git a/frontend/src/utils/date.ts b/frontend/src/utils/date.ts new file mode 100644 index 0000000..38a49b9 --- /dev/null +++ b/frontend/src/utils/date.ts @@ -0,0 +1,10 @@ +export type DatabaseDateValue = string | number + +export function parseDatabaseDate(value: DatabaseDateValue): Date { + if (typeof value === 'number') { + const timestamp = Math.abs(value) < 1_000_000_000_000 ? value * 1000 : value + return new Date(timestamp) + } + + return new Date(value.replace(' ', 'T')) +}