fix time zones close #21
This commit is contained in:
parent
20ba3ddaac
commit
fc4cbc1415
|
@ -43,7 +43,7 @@ const incrementInterval = () => {
|
||||||
|
|
||||||
const drawScreen = async () => {
|
const drawScreen = async () => {
|
||||||
// get the conditions
|
// get the conditions
|
||||||
const data = await getCurrentWeather(() => this.stillWaiting());
|
const data = await getCurrentWeather();
|
||||||
|
|
||||||
// nothing to do if there's no data yet
|
// nothing to do if there's no data yet
|
||||||
if (!data) return;
|
if (!data) return;
|
||||||
|
|
|
@ -77,7 +77,7 @@ const getWeather = async (latLon, haveDataCallback) => {
|
||||||
weatherParameters.weatherOffice = point.properties.cwa;
|
weatherParameters.weatherOffice = point.properties.cwa;
|
||||||
weatherParameters.city = city;
|
weatherParameters.city = city;
|
||||||
weatherParameters.state = point.properties.relativeLocation.properties.state;
|
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.forecast = point.properties.forecast;
|
||||||
weatherParameters.forecastGridData = point.properties.forecastGridData;
|
weatherParameters.forecastGridData = point.properties.forecastGridData;
|
||||||
weatherParameters.stations = stations.features;
|
weatherParameters.stations = stations.features;
|
||||||
|
@ -400,6 +400,8 @@ const registerRefreshData = (callback) => {
|
||||||
loadTwcData.callback = callback;
|
loadTwcData.callback = callback;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const timeZone = () => weatherParameters.timeZone;
|
||||||
|
|
||||||
export {
|
export {
|
||||||
updateStatus,
|
updateStatus,
|
||||||
displayNavMessage,
|
displayNavMessage,
|
||||||
|
@ -415,4 +417,5 @@ export {
|
||||||
latLonReceived,
|
latLonReceived,
|
||||||
stopAutoRefreshTimer,
|
stopAutoRefreshTimer,
|
||||||
registerRefreshData,
|
registerRefreshData,
|
||||||
|
timeZone,
|
||||||
};
|
};
|
||||||
|
|
|
@ -5,7 +5,7 @@ import { loadImg } from './utils/image.mjs';
|
||||||
import { text } from './utils/fetch.mjs';
|
import { text } from './utils/fetch.mjs';
|
||||||
import { rewriteUrl } from './utils/cors.mjs';
|
import { rewriteUrl } from './utils/cors.mjs';
|
||||||
import WeatherDisplay from './weatherdisplay.mjs';
|
import WeatherDisplay from './weatherdisplay.mjs';
|
||||||
import { registerDisplay } from './navigation.mjs';
|
import { registerDisplay, timeZone } from './navigation.mjs';
|
||||||
import * as utils from './radar-utils.mjs';
|
import * as utils from './radar-utils.mjs';
|
||||||
|
|
||||||
class Radar extends WeatherDisplay {
|
class Radar extends WeatherDisplay {
|
||||||
|
@ -159,7 +159,7 @@ class Radar extends WeatherDisplay {
|
||||||
zone: 'UTC',
|
zone: 'UTC',
|
||||||
}).setZone();
|
}).setZone();
|
||||||
} else {
|
} 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
|
// assign to an html image element
|
||||||
|
|
|
@ -2,9 +2,8 @@
|
||||||
|
|
||||||
import STATUS, { calcStatusClass, statusClasses } from './status.mjs';
|
import STATUS, { calcStatusClass, statusClasses } from './status.mjs';
|
||||||
import { DateTime } from '../vendor/auto/luxon.mjs';
|
import { DateTime } from '../vendor/auto/luxon.mjs';
|
||||||
import { elemForEach } from './utils/elem.mjs';
|
|
||||||
import {
|
import {
|
||||||
msg, displayNavMessage, isPlaying, updateStatus,
|
msg, displayNavMessage, isPlaying, updateStatus, timeZone,
|
||||||
} from './navigation.mjs';
|
} from './navigation.mjs';
|
||||||
|
|
||||||
class WeatherDisplay {
|
class WeatherDisplay {
|
||||||
|
@ -173,20 +172,22 @@ class WeatherDisplay {
|
||||||
// only draw if canvas is active to conserve battery
|
// only draw if canvas is active to conserve battery
|
||||||
if (!this.active) return;
|
if (!this.active) return;
|
||||||
// Get the current date and time.
|
// Get the current date and time.
|
||||||
const now = DateTime.local();
|
const now = DateTime.local().setZone(timeZone());
|
||||||
|
|
||||||
// time = "11:35:08 PM";
|
// time = "11:35:08 PM";
|
||||||
const time = now.toLocaleString(DateTime.TIME_WITH_SECONDS).padStart(11, ' ');
|
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) {
|
const dateElem = this.elem.querySelector('.date-time.date');
|
||||||
elemForEach('.date-time.time', (elem) => { elem.innerHTML = time.toUpperCase(); });
|
const timeElem = this.elem.querySelector('.date-time.time');
|
||||||
|
|
||||||
|
if (timeElem && this.lastTime !== time) {
|
||||||
|
timeElem.innerHTML = time.toUpperCase();
|
||||||
}
|
}
|
||||||
this.lastTime = time;
|
this.lastTime = time;
|
||||||
|
|
||||||
const date = now.toFormat(' ccc LLL ') + now.day.toString().padStart(2, ' ');
|
if (dateElem && this.lastDate !== date) {
|
||||||
|
dateElem.innerHTML = date.toUpperCase();
|
||||||
if (this.lastDate !== date) {
|
|
||||||
elemForEach('.date-time.date', (elem) => { elem.innerHTML = date.toUpperCase(); });
|
|
||||||
}
|
}
|
||||||
this.lastDate = date;
|
this.lastDate = date;
|
||||||
}
|
}
|
||||||
|
|
|
@ -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}) %>
|
||||||
<div class="main has-scroll has-box current-weather">
|
<div class="main has-scroll has-box current-weather">
|
||||||
<div class="weather template">
|
<div class="weather template">
|
||||||
<div class="left col">
|
<div class="left col">
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
<%- include('header.ejs', {titleDual:{ top: 'Latest' , bottom: 'Observations' }, noaaLogo: true }) %>
|
<%- include('header.ejs', {titleDual:{ top: 'Latest' , bottom: 'Observations' }, noaaLogo: true, hasTime: true }) %>
|
||||||
<div class="main has-scroll latest-observations has-box">
|
<div class="main has-scroll latest-observations has-box">
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<div class="column-headers">
|
<div class="column-headers">
|
||||||
|
|
Loading…
Reference in a new issue