mirror of
https://github.com/iptv-org/epg.git
synced 2025-05-10 00:50:09 -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 utc = require('dayjs/plugin/utc')
|
||||
const customParseFormat = require('dayjs/plugin/customParseFormat')
|
||||
const timezone = require('dayjs/plugin/timezone')
|
||||
|
||||
dayjs.extend(utc)
|
||||
dayjs.extend(customParseFormat)
|
||||
dayjs.extend(timezone)
|
||||
|
||||
module.exports = {
|
||||
site: 'mediaset.it',
|
||||
|
@ -19,20 +21,10 @@ module.exports = {
|
|||
if (!data.events) return programs
|
||||
|
||||
data.events.forEach(item => {
|
||||
if (item.title && item.startTime && item.endTime) {
|
||||
const start = dayjs
|
||||
.utc(item.startTime, 'HH:mm')
|
||||
.set('D', date.get('D'))
|
||||
.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()
|
||||
if (item.title && item.startTime && item.duration) {
|
||||
const start = parseStart(item, date)
|
||||
const duration = parseInt(item.duration)
|
||||
const stop = start.add(duration, 'm')
|
||||
|
||||
programs.push({
|
||||
title: item.displayTitle || item.title,
|
||||
|
@ -47,3 +39,7 @@ module.exports = {
|
|||
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