From 53918d274b9a33486e426847d395862513be3573 Mon Sep 17 00:00:00 2001 From: Gabriel Fosse Date: Thu, 5 Oct 2023 09:22:50 -0600 Subject: [PATCH 1/2] luxon timezone correction for tasmania --- src/adapters/tasmania.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/adapters/tasmania.js b/src/adapters/tasmania.js index 6cbea74a..d0eb4cf6 100644 --- a/src/adapters/tasmania.js +++ b/src/adapters/tasmania.js @@ -37,7 +37,7 @@ const formatData = function (data, source) { const date = DateTime.fromFormat( string.trim(), 'HHmmss', - { zone: 'Australia/Hobart' } + { zone: 'Australia/Tasmania' } ); if (!date.isValid) { From 638a931df7b63e225c03b380de695e64ee8377fe Mon Sep 17 00:00:00 2001 From: Gabriel Fosse Date: Fri, 6 Oct 2023 12:01:00 -0600 Subject: [PATCH 2/2] updated fix for Tasmania datetime --- src/adapters/tasmania.js | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/adapters/tasmania.js b/src/adapters/tasmania.js index d0eb4cf6..6d457047 100644 --- a/src/adapters/tasmania.js +++ b/src/adapters/tasmania.js @@ -12,7 +12,7 @@ import got from 'got'; export const name = 'tasmania'; -export function fetchData (source, cb) { +export function fetchData(source, cb) { got(source.url, { timeout: { request: REQUEST_TIMEOUT } }).then( (response) => { try { @@ -34,19 +34,21 @@ export function fetchData (source, cb) { const formatData = function (data, source) { const parseDate = function (string) { - const date = DateTime.fromFormat( - string.trim(), - 'HHmmss', - { zone: 'Australia/Tasmania' } - ); + const now = DateTime.now().setZone('Australia/Tasmania'); + + const hours = parseInt(string.substring(0, 2), 10); + const minutes = parseInt(string.substring(2, 4), 10); + const seconds = parseInt(string.substring(4, 6), 10); + + const date = now.set({ hour: hours, minute: minutes, second: seconds }); if (!date.isValid) { throw new Error('Invalid date format'); } return { - utc: date.toUTC().toISO({ suppressMilliseconds: true }), - local: date.toISO({ suppressMilliseconds: true }), + utc: date.toUTC().toFormat("yyyy-MM-dd'T'HH:mm:ssZZ"), + local: date.toFormat("yyyy-MM-dd'T'HH:mm:ssZZ"), }; };