vikunja/frontend/src/modelSchema/common/date.ts

11 lines
258 B
TypeScript

import {preprocess, date} from 'zod'
export const DateSchema = preprocess((arg) => {
if (
// FIXME: Add comment why we check for `0001`
typeof arg == 'string' && !arg.startsWith('0001') ||
arg instanceof Date
) {
return new Date(arg)
}
}, date())