Singtel.com timezone

Times from data source are local (UTC+8)
Added timezone to convert to UTC
This commit is contained in:
RevGear 2023-02-02 18:34:10 +00:00
parent adb58e4679
commit 9be87d7eb2
2 changed files with 8 additions and 6 deletions

View File

@ -1,11 +1,13 @@
const dayjs = require('dayjs')
const utc = require('dayjs/plugin/utc')
const timezone = require('dayjs/plugin/timezone')
dayjs.extend(utc)
dayjs.extend(timezone)
module.exports = {
site: 'singtel.com',
days: 2,
days: 3,
request: {
cache: {
ttl: 60 * 60 * 1000 // 1 hour
@ -18,7 +20,7 @@ module.exports = {
let programs = []
const items = parseItems(content, channel)
items.forEach(item => {
const start = dayjs.utc(item.startDateTime)
const start = dayjs.tz(item.startDateTime,'Asia/Singapore')
const stop = start.add(item.duration, 's')
programs.push({
title: item.program.title,

View File

@ -37,8 +37,8 @@ it('can parse response', () => {
expect(results.length).toBe(23)
expect(results[0]).toMatchObject({
start: '2023-01-29T00:00:00.000Z',
stop: '2023-01-29T01:30:00.000Z',
start: '2023-01-28T16:00:00.000Z',
stop: '2023-01-28T17:30:00.000Z',
title: 'Hip Hop Family Christmas Wedding',
description:
`Hip Hop's most famous family is back, and this time Christmas wedding bells are ringing! Jessica and Jayson are getting ready to say their "I do's".`,
@ -46,8 +46,8 @@ it('can parse response', () => {
})
expect(results[10]).toMatchObject({
start: '2023-01-29T09:00:00.000Z',
stop: '2023-01-29T09:30:00.000Z',
start: '2023-01-29T01:00:00.000Z',
stop: '2023-01-29T01:30:00.000Z',
title: 'The Daily Show',
description:
"The Daily Show correspondents tackle the biggest stories in news, politics and pop culture.",