From 9be87d7eb2deda47a3ad1da2b8fbada0930049c3 Mon Sep 17 00:00:00 2001 From: RevGear <95308545+RevGear@users.noreply.github.com> Date: Thu, 2 Feb 2023 18:34:10 +0000 Subject: [PATCH] Singtel.com timezone Times from data source are local (UTC+8) Added timezone to convert to UTC --- sites/singtel.com/singtel.com.config.js | 6 ++++-- sites/singtel.com/singtel.com.test.js | 8 ++++---- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/sites/singtel.com/singtel.com.config.js b/sites/singtel.com/singtel.com.config.js index ad5c3c94..eae6a302 100644 --- a/sites/singtel.com/singtel.com.config.js +++ b/sites/singtel.com/singtel.com.config.js @@ -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, diff --git a/sites/singtel.com/singtel.com.test.js b/sites/singtel.com/singtel.com.test.js index 0b007d33..72fd1769 100644 --- a/sites/singtel.com/singtel.com.test.js +++ b/sites/singtel.com/singtel.com.test.js @@ -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.",