actually set utc() + fixed time overflow detection

This commit is contained in:
MinePlayersPE 2021-06-21 19:59:23 +07:00
parent ac5fe18a91
commit ae36f830a5

View file

@ -34,17 +34,17 @@ module.exports = {
const title = (item.querySelector('div.b-livestreaming-daily-schedule__item-content-title') || { textContent: '' }).textContent 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 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') let start = dayjs(listdate.format('YYYY-MM-DD ').concat(time.substring(0,5)), 'YYYY-MM-DD HH:mm').utc()
let stop = dayjs(listdate.format('YYYY-MM-DD ').concat(time.substring(8,13)), 'YYYY-MM-DD HH:mm') let stop = dayjs(listdate.format('YYYY-MM-DD ').concat(time.substring(8,13)), 'YYYY-MM-DD HH:mm').utc()
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) { if (listdate.diff(date.format('YYYY-MM-DD'), 'd') === 0) {
programs.push({ programs.push({
title, title,
start.utc(), start,
stop.utc() stop
}) })
} }
} }