Add better support for time only date strings
This commit is contained in:
parent
989f54783c
commit
96bc6fc789
|
@ -56,8 +56,17 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
const parseValue = value => {
|
const parseValue = value => {
|
||||||
// Sanity check that we have a valid value
|
let parsedDate
|
||||||
const parsedDate = dayjs(value)
|
|
||||||
|
// 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()) {
|
if (!parsedDate?.isValid()) {
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue