Using and showing always local time
routes/api.js
- console.log deleted
public/javascripts/global.js
- made 'params' to const
- added setNoUTC in main
public/javascripts/showcharts.js
- added setNiUTC to set global at highcharts
package.json
- added luxon
"version": "3.0.4",
"date": "2023-04-24 18:00 UTC",
This commit is contained in:
@@ -10,6 +10,31 @@ export const showDate = (sofort) => {
|
||||
|
||||
}
|
||||
|
||||
/* ToDo:
|
||||
// Alle Minute die ktuelle Urzeit anzeigen und
|
||||
// den Plot für Tages - und Wochendaten updaten.
|
||||
// Alle 'refreshRate' plus 15sec die Grafiken neu zeichnen
|
||||
// Die Funktion wird alle Sekunde aufgerufen !
|
||||
//
|
||||
function showUhrzeit(sofort) {
|
||||
var d = moment() // akt. Zeit holen
|
||||
if (sofort || (d.second() == 0)) { // Wenn Minute grade um
|
||||
$('#h1uhr').html(d.format('HH:mm'));
|
||||
$('#subtitle').html(d.format('YYYY-MM-DD')); // dann zeit anzeigen
|
||||
}
|
||||
if (((d.minute() % refreshRate) == 0) && (d.second() == 15)) { // alle ganzen refreshRate Minuten, 15sec danach
|
||||
console.log(refreshRate, 'Minuten um, Grafik wird erneuert');
|
||||
if ((aktsensorid != 'map') && (doUpdate == true)) { // Wenn nicht die Karte, dann
|
||||
doPlot('oneday',startDay); // Tages- und
|
||||
doPlot('oneweek',startDay); // Wochenplot erneuern
|
||||
}
|
||||
else {
|
||||
fetchAktualData();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
*/
|
||||
export const formatJSDate = (d) => {
|
||||
return DateTime.fromJSDate(d).toFormat('yyyy-LL-dd HH:mm:ss')
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
import * as map from './map.js'
|
||||
import * as dt from './datetime.js'
|
||||
import {loadAll, showChart} from './showcharts.js'
|
||||
import {loadAll, showChart, setNoUTC} from './showcharts.js'
|
||||
import { DateTime } from './luxon.min.js'
|
||||
import {setCurrentTab, getCurrentTab, showError, fetchfromserver} from "./chart_utilities.js";
|
||||
|
||||
@@ -14,7 +14,7 @@ import {setCurrentTab, getCurrentTab, showError, fetchfromserver} from "./chart_
|
||||
// END global constants
|
||||
|
||||
// global variables
|
||||
let params = { // set defaults
|
||||
const params = { // set defaults
|
||||
center: Stuttgart,
|
||||
zoom: 10,
|
||||
span: 1,
|
||||
@@ -125,6 +125,8 @@ import {setCurrentTab, getCurrentTab, showError, fetchfromserver} from "./chart_
|
||||
// show the map if called w/o any parameter
|
||||
// if called with a sensor-ID, show the live chart for this sensor
|
||||
async function main() {
|
||||
setNoUTC() // no UTC for HighCharts
|
||||
console.log(Intl.DateTimeFormat().resolvedOptions().timeZone)
|
||||
// set correct language
|
||||
const currentLang = localStorage.getItem('curlang')
|
||||
if(currentLang === 'en') {
|
||||
|
||||
@@ -19,7 +19,7 @@ export async function showChart(params, typ, container) {
|
||||
function form() {
|
||||
for (let item of tabtable) {
|
||||
if (item.type === typ) {
|
||||
const d = DateTime.fromMillis(this.x, {zone: 'utc'})
|
||||
const d = DateTime.fromMillis(this.x)
|
||||
const d1 = d.plus({days: 1})
|
||||
let fmt = d.toFormat(item.dformat)
|
||||
if (((typ === 'daynight') && (this.series.name.startsWith('N'))) || (typ === 'lden')) {
|
||||
@@ -112,3 +112,11 @@ export const loadAll = async (params, start = 2) => {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export const setNoUTC = () => {
|
||||
Highcharts.setOptions({
|
||||
global: {
|
||||
useUTC: false // Don't use UTC on the charts
|
||||
}
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user