warsaw timezone
This commit is contained in:
+2
-2
@@ -48,7 +48,7 @@ def create_app():
|
|||||||
readouts = query.order_by(SensorReadout.timestamp.desc()).limit(300).all()
|
readouts = query.order_by(SensorReadout.timestamp.desc()).limit(300).all()
|
||||||
return jsonify(
|
return jsonify(
|
||||||
[
|
[
|
||||||
{"value": r.value, "timestamp": r.timestamp.isoformat()}
|
{"value": r.value, "timestamp": r.timestamp.isoformat() + "Z"}
|
||||||
for r in readouts
|
for r in readouts
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
@@ -124,7 +124,7 @@ def create_app():
|
|||||||
"sensor_id": readout.sensor_id,
|
"sensor_id": readout.sensor_id,
|
||||||
"type": readout.type,
|
"type": readout.type,
|
||||||
"value": readout.value,
|
"value": readout.value,
|
||||||
"timestamp": readout.timestamp.isoformat(),
|
"timestamp": readout.timestamp.isoformat() + "Z",
|
||||||
}
|
}
|
||||||
), 201
|
), 201
|
||||||
|
|
||||||
|
|||||||
@@ -61,11 +61,12 @@
|
|||||||
|
|
||||||
function formatTimestamp(iso) {
|
function formatTimestamp(iso) {
|
||||||
const d = new Date(iso);
|
const d = new Date(iso);
|
||||||
const pad = (n) => String(n).padStart(2, '0');
|
return d.toLocaleString('pl-PL', { timeZone: 'Europe/Warsaw' });
|
||||||
const months = ['Jan','Feb','Mar','Apr','May','Jun',
|
}
|
||||||
'Jul','Aug','Sep','Oct','Nov','Dec'];
|
|
||||||
return `${d.getDate()} ${months[d.getMonth()]} ${d.getFullYear()}, ` +
|
function formatChartLabel(iso) {
|
||||||
`${pad(d.getHours())}:${pad(d.getMinutes())}:${pad(d.getSeconds())}`;
|
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) {
|
async function fetchJSON(url) {
|
||||||
@@ -114,7 +115,7 @@
|
|||||||
|
|
||||||
// fetch hourly data for chart
|
// fetch hourly data for chart
|
||||||
const hourly = await fetchJSON(`/api/sensors/${sensorId}/readouts/hourly?type=${type}`);
|
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);
|
const values = hourly.map(r => r.value);
|
||||||
|
|
||||||
if (chart) chart.destroy();
|
if (chart) chart.destroy();
|
||||||
|
|||||||
@@ -8,6 +8,6 @@ typedef struct {
|
|||||||
} ygg_sensor_readout;
|
} ygg_sensor_readout;
|
||||||
|
|
||||||
extern ygg_sensor_readout CURR_READOUT;
|
extern ygg_sensor_readout CURR_READOUT;
|
||||||
static const char *SENSOR_NAME = "BMP_280_SENSOR_001";
|
static const char *SENSOR_NAME = "BMP_280";
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user