mirror of
https://github.com/iptv-org/epg.git
synced 2025-05-10 09:00:07 -04:00
Set timezone offset
Fixes issue 2184
This commit is contained in:
parent
ecdf161a71
commit
47b06eb9f3
1 changed files with 10 additions and 14 deletions
|
@ -1,9 +1,11 @@
|
||||||
const dayjs = require('dayjs')
|
const dayjs = require('dayjs')
|
||||||
const utc = require('dayjs/plugin/utc')
|
const utc = require('dayjs/plugin/utc')
|
||||||
const customParseFormat = require('dayjs/plugin/customParseFormat')
|
const customParseFormat = require('dayjs/plugin/customParseFormat')
|
||||||
|
const timezone = require('dayjs/plugin/timezone')
|
||||||
|
|
||||||
dayjs.extend(utc)
|
dayjs.extend(utc)
|
||||||
dayjs.extend(customParseFormat)
|
dayjs.extend(customParseFormat)
|
||||||
|
dayjs.extend(timezone)
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
site: 'mediaset.it',
|
site: 'mediaset.it',
|
||||||
|
@ -19,20 +21,10 @@ module.exports = {
|
||||||
if (!data.events) return programs
|
if (!data.events) return programs
|
||||||
|
|
||||||
data.events.forEach(item => {
|
data.events.forEach(item => {
|
||||||
if (item.title && item.startTime && item.endTime) {
|
if (item.title && item.startTime && item.duration) {
|
||||||
const start = dayjs
|
const start = parseStart(item, date)
|
||||||
.utc(item.startTime, 'HH:mm')
|
const duration = parseInt(item.duration)
|
||||||
.set('D', date.get('D'))
|
const stop = start.add(duration, 'm')
|
||||||
.set('M', date.get('M'))
|
|
||||||
.set('y', date.get('y'))
|
|
||||||
.toString()
|
|
||||||
|
|
||||||
const stop = dayjs
|
|
||||||
.utc(item.endTime, 'HH:mm')
|
|
||||||
.set('D', date.get('D'))
|
|
||||||
.set('M', date.get('M'))
|
|
||||||
.set('y', date.get('y'))
|
|
||||||
.toString()
|
|
||||||
|
|
||||||
programs.push({
|
programs.push({
|
||||||
title: item.displayTitle || item.title,
|
title: item.displayTitle || item.title,
|
||||||
|
@ -47,3 +39,7 @@ module.exports = {
|
||||||
return programs
|
return programs
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function parseStart(item, date) {
|
||||||
|
return dayjs.tz(`${date.format('YYYY-MM-DD')} ${item.startTime}`, 'YYYY-MM-DD HH:mm', 'Europe/Rome')
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue