mirror of
https://github.com/comatory/fb2iCal
synced 2025-06-05 22:09:25 +02:00
add fallback parser when LD/JSON not found, use DOM parser
This commit is contained in:
32
lib/parser-utils.js
Normal file
32
lib/parser-utils.js
Normal file
@@ -0,0 +1,32 @@
|
||||
const dayjs = require('dayjs')
|
||||
|
||||
// NOTE: Specific formatting for `ics` library
|
||||
const parseDates = (startDate, endDate) => {
|
||||
const start = startDate ? [
|
||||
startDate.year(),
|
||||
startDate.month() + 1,
|
||||
startDate.date(),
|
||||
startDate.hour(),
|
||||
startDate.minute(),
|
||||
] : (() => {
|
||||
const now = dayjs()
|
||||
|
||||
return [
|
||||
now.year(),
|
||||
now.month() + 1,
|
||||
now.date()
|
||||
]
|
||||
})()
|
||||
const diffInMinutes = endDate ?
|
||||
endDate.diff(startDate, 'minutes') :
|
||||
120
|
||||
|
||||
const duration = { minutes: diffInMinutes }
|
||||
|
||||
return {
|
||||
start,
|
||||
duration,
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = { parseDates }
|
Reference in New Issue
Block a user