diff --git a/public/city-select.html b/public/city-select.html
index f598762..72e858f 100644
--- a/public/city-select.html
+++ b/public/city-select.html
@@ -184,7 +184,7 @@
diff --git a/public/dashboard.html b/public/dashboard.html
index 11dd36c..6104a15 100644
--- a/public/dashboard.html
+++ b/public/dashboard.html
@@ -701,9 +701,14 @@
activeStationId = stationId; // Track which station we're updating
document.getElementById('updateModal').style.display = 'block';
- // Set current date/time as default
+ // Set current date/time as default in local timezone
const now = new Date();
- const localDateTime = new Date(now.getTime() - now.getTimezoneOffset() * 60000).toISOString().slice(0, 16);
+ const year = now.getFullYear();
+ const month = String(now.getMonth() + 1).padStart(2, '0');
+ const day = String(now.getDate()).padStart(2, '0');
+ const hours = String(now.getHours()).padStart(2, '0');
+ const minutes = String(now.getMinutes()).padStart(2, '0');
+ const localDateTime = `${year}-${month}-${day}T${hours}:${minutes}`;
document.getElementById('statusAsOf').value = localDateTime;
// Center map on selected station
@@ -892,10 +897,19 @@
}
const formData = new FormData(e.target);
+ const statusAsOfLocal = formData.get('statusAsOf');
+
+ // Convert local datetime to UTC for server
+ let statusAsOfUTC = null;
+ if (statusAsOfLocal) {
+ const localDate = new Date(statusAsOfLocal);
+ statusAsOfUTC = localDate.toISOString();
+ }
+
const data = {
description: formData.get('description'),
estimatedHours: formData.get('estimatedHours'),
- statusAsOf: formData.get('statusAsOf')
+ statusAsOf: statusAsOfUTC
};
try {
diff --git a/server.js b/server.js
index 9ff6e23..9990192 100644
--- a/server.js
+++ b/server.js
@@ -400,6 +400,7 @@ app.post('/api/stations/:id/update', (req, res) => {
const stationId = req.params.id;
// Use provided status date/time or current time
+ // statusAsOf now comes as UTC ISO string from client
const refillTime = statusAsOf ? new Date(statusAsOf) : new Date();
const estimatedEmptyTime = new Date(refillTime);