diff --git a/server/scripts/modules/currentweatherscroll.mjs b/server/scripts/modules/currentweatherscroll.mjs index c8e782c..c90f3d2 100644 --- a/server/scripts/modules/currentweatherscroll.mjs +++ b/server/scripts/modules/currentweatherscroll.mjs @@ -43,7 +43,7 @@ const incrementInterval = () => { const drawScreen = async () => { // get the conditions - const data = await getCurrentWeather(() => this.stillWaiting()); + const data = await getCurrentWeather(); // nothing to do if there's no data yet if (!data) return; diff --git a/server/scripts/modules/navigation.mjs b/server/scripts/modules/navigation.mjs index da6e3e0..0de648a 100644 --- a/server/scripts/modules/navigation.mjs +++ b/server/scripts/modules/navigation.mjs @@ -77,7 +77,7 @@ const getWeather = async (latLon, haveDataCallback) => { weatherParameters.weatherOffice = point.properties.cwa; weatherParameters.city = city; weatherParameters.state = point.properties.relativeLocation.properties.state; - weatherParameters.timeZone = point.properties.relativeLocation.properties.timeZone; + weatherParameters.timeZone = point.properties.timeZone; weatherParameters.forecast = point.properties.forecast; weatherParameters.forecastGridData = point.properties.forecastGridData; weatherParameters.stations = stations.features; @@ -400,6 +400,8 @@ const registerRefreshData = (callback) => { loadTwcData.callback = callback; }; +const timeZone = () => weatherParameters.timeZone; + export { updateStatus, displayNavMessage, @@ -415,4 +417,5 @@ export { latLonReceived, stopAutoRefreshTimer, registerRefreshData, + timeZone, }; diff --git a/server/scripts/modules/radar.mjs b/server/scripts/modules/radar.mjs index 94ffab3..f0b3894 100644 --- a/server/scripts/modules/radar.mjs +++ b/server/scripts/modules/radar.mjs @@ -5,7 +5,7 @@ import { loadImg } from './utils/image.mjs'; import { text } from './utils/fetch.mjs'; import { rewriteUrl } from './utils/cors.mjs'; import WeatherDisplay from './weatherdisplay.mjs'; -import { registerDisplay } from './navigation.mjs'; +import { registerDisplay, timeZone } from './navigation.mjs'; import * as utils from './radar-utils.mjs'; class Radar extends WeatherDisplay { @@ -159,7 +159,7 @@ class Radar extends WeatherDisplay { zone: 'UTC', }).setZone(); } else { - time = DateTime.fromHTTP(response.headers.get('last-modified')).setZone(); + time = DateTime.fromHTTP(response.headers.get('last-modified')).setZone(timeZone()); } // assign to an html image element diff --git a/server/scripts/modules/weatherdisplay.mjs b/server/scripts/modules/weatherdisplay.mjs index 36f373d..e1bc535 100644 --- a/server/scripts/modules/weatherdisplay.mjs +++ b/server/scripts/modules/weatherdisplay.mjs @@ -2,9 +2,8 @@ import STATUS, { calcStatusClass, statusClasses } from './status.mjs'; import { DateTime } from '../vendor/auto/luxon.mjs'; -import { elemForEach } from './utils/elem.mjs'; import { - msg, displayNavMessage, isPlaying, updateStatus, + msg, displayNavMessage, isPlaying, updateStatus, timeZone, } from './navigation.mjs'; class WeatherDisplay { @@ -173,20 +172,22 @@ class WeatherDisplay { // only draw if canvas is active to conserve battery if (!this.active) return; // Get the current date and time. - const now = DateTime.local(); + const now = DateTime.local().setZone(timeZone()); // time = "11:35:08 PM"; const time = now.toLocaleString(DateTime.TIME_WITH_SECONDS).padStart(11, ' '); + const date = now.toFormat(' ccc LLL ') + now.day.toString().padStart(2, ' '); - if (this.lastTime !== time) { - elemForEach('.date-time.time', (elem) => { elem.innerHTML = time.toUpperCase(); }); + const dateElem = this.elem.querySelector('.date-time.date'); + const timeElem = this.elem.querySelector('.date-time.time'); + + if (timeElem && this.lastTime !== time) { + timeElem.innerHTML = time.toUpperCase(); } this.lastTime = time; - const date = now.toFormat(' ccc LLL ') + now.day.toString().padStart(2, ' '); - - if (this.lastDate !== date) { - elemForEach('.date-time.date', (elem) => { elem.innerHTML = date.toUpperCase(); }); + if (dateElem && this.lastDate !== date) { + dateElem.innerHTML = date.toUpperCase(); } this.lastDate = date; } diff --git a/views/partials/current-weather.ejs b/views/partials/current-weather.ejs index ee585ce..f5224f7 100644 --- a/views/partials/current-weather.ejs +++ b/views/partials/current-weather.ejs @@ -1,4 +1,4 @@ -<%- include('header.ejs', {titleDual:{ top: 'Current' , bottom: 'Conditions' }, noaaLogo: true}) %> +<%- include('header.ejs', {titleDual:{ top: 'Current' , bottom: 'Conditions' }, noaaLogo: true, hasTime: true}) %>