From ceb2431f8e9569b10c1a716f558104cfbd4c4c10 Mon Sep 17 00:00:00 2001 From: Mateusz Date: Sun, 20 Sep 2026 18:24:32 +0200 Subject: [PATCH] warsaw timezone --- server/app.py | 4 ++-- server/templates/sensors.html | 13 +++++++------ thermo_sensor/main/ygg_state.h | 2 +- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/server/app.py b/server/app.py index ddd1164..7f82c12 100644 --- a/server/app.py +++ b/server/app.py @@ -48,7 +48,7 @@ def create_app(): readouts = query.order_by(SensorReadout.timestamp.desc()).limit(300).all() return jsonify( [ - {"value": r.value, "timestamp": r.timestamp.isoformat()} + {"value": r.value, "timestamp": r.timestamp.isoformat() + "Z"} for r in readouts ] ) @@ -124,7 +124,7 @@ def create_app(): "sensor_id": readout.sensor_id, "type": readout.type, "value": readout.value, - "timestamp": readout.timestamp.isoformat(), + "timestamp": readout.timestamp.isoformat() + "Z", } ), 201 diff --git a/server/templates/sensors.html b/server/templates/sensors.html index 2776d27..e2f640c 100644 --- a/server/templates/sensors.html +++ b/server/templates/sensors.html @@ -61,11 +61,12 @@ function formatTimestamp(iso) { const d = new Date(iso); - const pad = (n) => String(n).padStart(2, '0'); - const months = ['Jan','Feb','Mar','Apr','May','Jun', - 'Jul','Aug','Sep','Oct','Nov','Dec']; - return `${d.getDate()} ${months[d.getMonth()]} ${d.getFullYear()}, ` + - `${pad(d.getHours())}:${pad(d.getMinutes())}:${pad(d.getSeconds())}`; + return d.toLocaleString('pl-PL', { timeZone: 'Europe/Warsaw' }); + } + + function formatChartLabel(iso) { + const d = new Date(iso + 'Z'); + return d.toLocaleString('pl-PL', { timeZone: 'Europe/Warsaw', hour: '2-digit', minute: '2-digit', day: '2-digit', month: '2-digit', year: 'numeric' }); } async function fetchJSON(url) { @@ -114,7 +115,7 @@ // fetch hourly data for chart const hourly = await fetchJSON(`/api/sensors/${sensorId}/readouts/hourly?type=${type}`); - const labels = hourly.map(r => r.timestamp.replace('T', ' ')); + const labels = hourly.map(r => formatChartLabel(r.timestamp)); const values = hourly.map(r => r.value); if (chart) chart.destroy(); diff --git a/thermo_sensor/main/ygg_state.h b/thermo_sensor/main/ygg_state.h index 2ba4def..8bde21c 100644 --- a/thermo_sensor/main/ygg_state.h +++ b/thermo_sensor/main/ygg_state.h @@ -8,6 +8,6 @@ typedef struct { } ygg_sensor_readout; extern ygg_sensor_readout CURR_READOUT; -static const char *SENSOR_NAME = "BMP_280_SENSOR_001"; +static const char *SENSOR_NAME = "BMP_280"; #endif