kolaente
aa5e11915e
All checks were successful
continuous-integration/drone/push Build is passing
Resolves https://community.vikunja.io/t/filter-setting-s/1791/2
16 lines
383 B
TypeScript
16 lines
383 B
TypeScript
export function parseDateOrString(rawValue: string | undefined | null, fallback: unknown): (unknown | string | Date) {
|
|
if (rawValue === null || typeof rawValue === 'undefined') {
|
|
return fallback
|
|
}
|
|
|
|
if (rawValue.toLowerCase().includes('now') || rawValue.toLowerCase().includes('||')) {
|
|
return rawValue
|
|
}
|
|
|
|
const d = new Date(rawValue)
|
|
|
|
return !isNaN(+d)
|
|
? d
|
|
: rawValue
|
|
}
|