improve parsing for start and end dates for DOMparser
This commit is contained in:
parent
7234d442e3
commit
f22841e1f4
|
@ -14,10 +14,16 @@ const parseDate = (timeText) => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const normalizedTimeString = `${datePart}${timePart || ''}`
|
const rangeTimeParts = timePart ? timePart.split('–') : []
|
||||||
const startTime = dayjs(normalizedTimeString)
|
const startTimePart = `${datePart || ''}${rangeTimeParts[0] || ''}`
|
||||||
|
const endTimePart = `${datePart || ''}${rangeTimeParts[1] || ''}`
|
||||||
|
|
||||||
const { start, duration } = parseDates(startTime, null)
|
const startTime = dayjs(startTimePart)
|
||||||
|
const endTime = dayjs(endTimePart)
|
||||||
|
|
||||||
|
const normalizedStartTime = startTime.isValid() ? startTime : dayjs(new Date())
|
||||||
|
const normalizedEndTime = endTime.isValid() ? endTime : dayjs(new Date())
|
||||||
|
const { start, duration } = parseDates(normalizedStartTime, normalizedEndTime)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
start,
|
start,
|
||||||
|
|
Loading…
Reference in New Issue