mirror of
https://github.com/comatory/fb2iCal
synced 2024-12-25 16:02:46 +01:00
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 startTime = dayjs(normalizedTimeString)
|
||||
const rangeTimeParts = timePart ? timePart.split('–') : []
|
||||
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 {
|
||||
start,
|
||||
|
Loading…
Reference in New Issue
Block a user