mirror of
https://github.com/iptv-org/epg.git
synced 2025-05-12 10:00:08 -04:00
Fixes timezone issue
This commit is contained in:
parent
c88424e16d
commit
2208f7a0d2
1 changed files with 41 additions and 27 deletions
|
@ -8,7 +8,6 @@ const timezone = require('dayjs/plugin/timezone')
|
||||||
dayjs.extend(utc)
|
dayjs.extend(utc)
|
||||||
dayjs.extend(customParseFormat)
|
dayjs.extend(customParseFormat)
|
||||||
dayjs.extend(timezone)
|
dayjs.extend(timezone)
|
||||||
dayjs.tz.setDefault('Asia/Jakarta')
|
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
lang: 'id',
|
lang: 'id',
|
||||||
|
@ -22,33 +21,48 @@ module.exports = {
|
||||||
const programs = []
|
const programs = []
|
||||||
const dom = new JSDOM(content)
|
const dom = new JSDOM(content)
|
||||||
|
|
||||||
const currdate = dayjs(
|
const scheduleDate = dom.window.document.querySelector(
|
||||||
dom.window.document.querySelector('div.b-livestreaming-daily-schedule__date-label').textContent)
|
'div.b-livestreaming-daily-schedule__date-label'
|
||||||
const lists = dom.window.document.querySelectorAll('div.b-livestreaming-daily-schedule__content')
|
).textContent
|
||||||
lists.forEach(list => {
|
const currdate = dayjs(scheduleDate)
|
||||||
const listdate = currdate.add(
|
const list = dom.window.document.querySelector(
|
||||||
JSON.parse(list.querySelector('div.b-livestreaming-schedule__ahoy-impression').getAttribute('data-ahoy-props') || {}).schedule_day, 'day')
|
`#schedule-content-${currdate.format(
|
||||||
|
'YYYYMMDD'
|
||||||
|
)} > .b-livestreaming-daily-schedule__scroll-container`
|
||||||
|
)
|
||||||
const items = list.querySelectorAll('div.b-livestreaming-daily-schedule__item')
|
const items = list.querySelectorAll('div.b-livestreaming-daily-schedule__item')
|
||||||
items.forEach(item => {
|
items.forEach(item => {
|
||||||
const title = (item.querySelector('div.b-livestreaming-daily-schedule__item-content-title') || { textContent: '' }).textContent
|
const title = (
|
||||||
const time = (item.querySelector('div.b-livestreaming-daily-schedule__item-content-caption') || { textContent: '' }).textContent
|
item.querySelector('div.b-livestreaming-daily-schedule__item-content-title') || {
|
||||||
|
textContent: ''
|
||||||
|
}
|
||||||
|
).textContent
|
||||||
|
const time = (
|
||||||
|
item.querySelector('div.b-livestreaming-daily-schedule__item-content-caption') || {
|
||||||
|
textContent: ''
|
||||||
|
}
|
||||||
|
).textContent
|
||||||
if (title && time) {
|
if (title && time) {
|
||||||
let start = dayjs(listdate.format('YYYY-MM-DD ').concat(time.substring(0,5)), 'YYYY-MM-DD HH:mm').subtract(7, 'hour')
|
let start = dayjs.tz(
|
||||||
let stop = dayjs(listdate.format('YYYY-MM-DD ').concat(time.substring(8,13)), 'YYYY-MM-DD HH:mm').subtract(7, 'hour')
|
currdate.format('YYYY-MM-DD ').concat(time.substring(0, 5)),
|
||||||
|
'YYYY-MM-DD HH:mm',
|
||||||
|
'Asia/Jakarta'
|
||||||
|
)
|
||||||
|
let stop = dayjs.tz(
|
||||||
|
currdate.format('YYYY-MM-DD ').concat(time.substring(8, 13)),
|
||||||
|
'YYYY-MM-DD HH:mm',
|
||||||
|
'Asia/Jakarta'
|
||||||
|
)
|
||||||
if (start.diff(stop, 'h') > 0) {
|
if (start.diff(stop, 'h') > 0) {
|
||||||
stop = stop.add(1, 'day')
|
stop = stop.add(1, 'day')
|
||||||
}
|
}
|
||||||
|
|
||||||
if (listdate.diff(date.format('YYYY-MM-DD'), 'd') === 0) {
|
|
||||||
programs.push({
|
programs.push({
|
||||||
title,
|
title,
|
||||||
start,
|
start,
|
||||||
stop
|
stop
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
|
|
||||||
return programs
|
return programs
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue