updated the sheet

This commit is contained in:
2026-08-28 18:16:28 +05:30
parent 69f4f3e909
commit 074cc0eccf
43 changed files with 2617 additions and 1201 deletions

View File

@@ -135,9 +135,32 @@ class MilerApi {
/// Telemetry wants strings for values that are numbers everywhere else.
static String _str(dynamic v) => v == null ? '' : v.toString();
/// `YYYY-MM-DD HH:MM:SS`, IST wall-clock, for telemetry `logdate`.
/// `YYYY-MM-DD HH:MM:SS`, the phone's **local wall clock**, for `logdate`.
///
/// ── This was briefly changed to UTC, and that was wrong ──
///
/// The reasoning looked sound: the field carries no zone suffix, so one side
/// has to name the convention, and UTC is the usual answer. It is not the
/// answer here. The Doormile backend's read range — `DBNow` / `DBToday` — and
/// the database itself run on **IST wall-clock**, so a UTC stamp from an
/// Indian handset lands 5h30m *behind* the window the console asks for, and
/// after 18:30 local it files the evening's work under the previous day.
///
/// Confirmed against the live backend on 28 Aug 2026, after the UTC change
/// had already shipped to a test build. It went unnoticed there because that
/// handset's own clock was running on UTC, so local and UTC agreed and the
/// rows landed in the window anyway.
///
/// So: local, and the phone's timezone is assumed to be the fleet's. That is
/// true for every Doormile Miler today. The durable fix is an offset on the
/// wire — an ISO-8601 stamp the backend parses with its zone — and until the
/// contract carries one, this is the convention both sides have agreed.
static String logStamp([DateTime? at]) {
final t = at ?? DateTime.now();
// `.toLocal()` because a caller can hand this a UTC `DateTime` — the
// consignment breadcrumb does — and reading `.hour` off one of those
// renders the UTC wall clock, which is the bug this method just came back
// from. A local `DateTime` passes through unchanged.
final t = (at ?? DateTime.now()).toLocal();
String p(int n) => n.toString().padLeft(2, '0');
return '${t.year}-${p(t.month)}-${p(t.day)} '
'${p(t.hour)}:${p(t.minute)}:${p(t.second)}';