Add better support for time only date strings

This commit is contained in:
Andrew Kingston 2023-11-03 17:05:27 +00:00
parent 989f54783c
commit 96bc6fc789
1 changed files with 11 additions and 2 deletions

View File

@ -56,8 +56,17 @@
}
const parseValue = value => {
// Sanity check that we have a valid value
const parsedDate = dayjs(value)
let parsedDate
// Attempt to parse as a time-only string if required
if (typeof value === "string" && timeOnly) {
parsedDate = dayjs(`0-${value}`)
}
// Attempt to parse as normal if required
if (!parsedDate?.isValid()) {
parsedDate = dayjs(value)
}
if (!parsedDate?.isValid()) {
return null
}