fix time zones close #21
This commit is contained in:
parent
20ba3ddaac
commit
fc4cbc1415
|
@ -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;
|
||||
|
|
|
@ -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,
|
||||
};
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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="weather template">
|
||||
<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="container">
|
||||
<div class="column-headers">
|
||||
|
|
Loading…
Reference in a new issue