mirror of
https://github.com/iptv-org/epg.git
synced 2025-05-11 09:30:06 -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(customParseFormat)
|
||||
dayjs.extend(timezone)
|
||||
dayjs.tz.setDefault('Asia/Jakarta')
|
||||
|
||||
module.exports = {
|
||||
lang: 'id',
|
||||
|
@ -22,33 +21,48 @@ module.exports = {
|
|||
const programs = []
|
||||
const dom = new JSDOM(content)
|
||||
|
||||
const currdate = dayjs(
|
||||
dom.window.document.querySelector('div.b-livestreaming-daily-schedule__date-label').textContent)
|
||||
const lists = dom.window.document.querySelectorAll('div.b-livestreaming-daily-schedule__content')
|
||||
lists.forEach(list => {
|
||||
const listdate = currdate.add(
|
||||
JSON.parse(list.querySelector('div.b-livestreaming-schedule__ahoy-impression').getAttribute('data-ahoy-props') || {}).schedule_day, 'day')
|
||||
|
||||
const items = list.querySelectorAll('div.b-livestreaming-daily-schedule__item')
|
||||
items.forEach(item => {
|
||||
const title = (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) {
|
||||
let start = dayjs(listdate.format('YYYY-MM-DD ').concat(time.substring(0,5)), 'YYYY-MM-DD HH:mm').subtract(7, 'hour')
|
||||
let stop = dayjs(listdate.format('YYYY-MM-DD ').concat(time.substring(8,13)), 'YYYY-MM-DD HH:mm').subtract(7, 'hour')
|
||||
if (start.diff(stop, 'h') > 0) {
|
||||
stop = stop.add(1, 'day')
|
||||
}
|
||||
|
||||
if (listdate.diff(date.format('YYYY-MM-DD'), 'd') === 0) {
|
||||
programs.push({
|
||||
title,
|
||||
start,
|
||||
stop
|
||||
})
|
||||
}
|
||||
const scheduleDate = dom.window.document.querySelector(
|
||||
'div.b-livestreaming-daily-schedule__date-label'
|
||||
).textContent
|
||||
const currdate = dayjs(scheduleDate)
|
||||
const list = dom.window.document.querySelector(
|
||||
`#schedule-content-${currdate.format(
|
||||
'YYYYMMDD'
|
||||
)} > .b-livestreaming-daily-schedule__scroll-container`
|
||||
)
|
||||
const items = list.querySelectorAll('div.b-livestreaming-daily-schedule__item')
|
||||
items.forEach(item => {
|
||||
const title = (
|
||||
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) {
|
||||
let start = dayjs.tz(
|
||||
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) {
|
||||
stop = stop.add(1, 'day')
|
||||
}
|
||||
|
||||
programs.push({
|
||||
title,
|
||||
start,
|
||||
stop
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
return programs
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue