mirror of
https://github.com/iptv-org/epg.git
synced 2025-05-10 00:50:09 -04:00
parent
42720ad62c
commit
ce7f70d351
2 changed files with 18 additions and 8 deletions
|
@ -1,7 +1,9 @@
|
||||||
const dayjs = require('dayjs')
|
const dayjs = require('dayjs')
|
||||||
|
const timezone = require('dayjs/plugin/timezone')
|
||||||
const utc = require('dayjs/plugin/utc')
|
const utc = require('dayjs/plugin/utc')
|
||||||
var customParseFormat = require('dayjs/plugin/customParseFormat')
|
var customParseFormat = require('dayjs/plugin/customParseFormat')
|
||||||
dayjs.extend(utc)
|
dayjs.extend(utc)
|
||||||
|
dayjs.extend(timezone)
|
||||||
dayjs.extend(customParseFormat)
|
dayjs.extend(customParseFormat)
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
|
@ -15,8 +17,16 @@ module.exports = {
|
||||||
if (!items.length) return programs
|
if (!items.length) return programs
|
||||||
let guideDate = date
|
let guideDate = date
|
||||||
items.forEach(item => {
|
items.forEach(item => {
|
||||||
let startTime = dayjs.utc(`${guideDate.format('YYYY-MM-DD')} ${item.HORA_INICIO}`,"YYYY-MM-DD HH:mm")
|
let startTime = dayjs.tz(
|
||||||
let stopTime = dayjs.utc(`${guideDate.format('YYYY-MM-DD')} ${item.HORA_FIN}`, 'YYYY-MM-DD HH:mm')
|
`${guideDate.format('YYYY-MM-DD')} ${item.HORA_INICIO}`,
|
||||||
|
'YYYY-MM-DD HH:mm',
|
||||||
|
'Europe/Madrid'
|
||||||
|
)
|
||||||
|
let stopTime = dayjs.tz(
|
||||||
|
`${guideDate.format('YYYY-MM-DD')} ${item.HORA_FIN}`,
|
||||||
|
'YYYY-MM-DD HH:mm',
|
||||||
|
'Europe/Madrid'
|
||||||
|
)
|
||||||
if (stopTime.isBefore(startTime)) {
|
if (stopTime.isBefore(startTime)) {
|
||||||
guideDate = guideDate.add(1, 'd')
|
guideDate = guideDate.add(1, 'd')
|
||||||
stopTime = stopTime.add(1, 'd')
|
stopTime = stopTime.add(1, 'd')
|
||||||
|
|
|
@ -22,20 +22,20 @@ it('can parse response', () => {
|
||||||
const result = parser({ content, channel, date })
|
const result = parser({ content, channel, date })
|
||||||
expect(result).toMatchObject([
|
expect(result).toMatchObject([
|
||||||
{
|
{
|
||||||
start: '2022-03-11T06:00:00.000Z',
|
start: '2022-03-11T05:00:00.000Z',
|
||||||
stop: '2022-03-11T08:30:00.000Z',
|
stop: '2022-03-11T07:30:00.000Z',
|
||||||
category: 'Información',
|
category: 'Información',
|
||||||
title: `Telediario Matinal`
|
title: `Telediario Matinal`
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
start: '2022-03-11T22:15:00.000Z',
|
start: '2022-03-11T21:15:00.000Z',
|
||||||
stop: '2022-03-12T00:30:00.000Z',
|
stop: '2022-03-11T23:30:00.000Z',
|
||||||
category: 'Información',
|
category: 'Información',
|
||||||
title: `Las Claves del Siglo XXI: Episodio 8`
|
title: `Las Claves del Siglo XXI: Episodio 8`
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
start: '2022-03-12T03:10:00.000Z',
|
start: '2022-03-12T02:10:00.000Z',
|
||||||
stop: '2022-03-12T06:00:00.000Z',
|
stop: '2022-03-12T05:00:00.000Z',
|
||||||
category: 'Información',
|
category: 'Información',
|
||||||
title: `Noticias 24H`
|
title: `Noticias 24H`
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue