From df49d99af4352f9eb38966ca924279ad7b180f62 Mon Sep 17 00:00:00 2001 From: Dmitry Date: Sat, 19 Sep 2026 10:56:42 +0300 Subject: [PATCH] =?UTF-8?q?fix(app):=20=D0=B4=D0=B0=D1=82=D0=B0=20=D0=B1?= =?UTF-8?q?=D0=B5=D0=B7=20=D0=B2=D1=80=D0=B5=D0=BC=D0=B5=D0=BD=D0=B8=20?= =?UTF-8?q?=D0=BF=D0=B0=D1=80=D1=81=D0=B8=D1=82=D1=81=D1=8F=20=D0=BA=D0=B0?= =?UTF-8?q?=D0=BA=20UTC,=20=D0=B0=20=D0=BD=D0=B5=20=D0=B2=20=D0=BB=D0=BE?= =?UTF-8?q?=D0=BA=D0=B0=D0=BB=D1=8C=D0=BD=D0=BE=D0=B9=20=D0=B7=D0=BE=D0=BD?= =?UTF-8?q?=D0=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit DateTime.tryParse("2026-09-18") в Dart возвращает локальное время, не UTC — на MSK (UTC+3) это трёхчасовой сдвиг относительно того, что сервер имел в виду датой без времени. asDate() перетэговывает те же значения полей как UTC вместо доверия tryParse; настоящий таймстемп с "Z"/смещением проходит насквозь без изменений. --- app/lib/core/utils/json.dart | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/app/lib/core/utils/json.dart b/app/lib/core/utils/json.dart index d891f94..970fd7d 100644 --- a/app/lib/core/utils/json.dart +++ b/app/lib/core/utils/json.dart @@ -29,7 +29,23 @@ bool asBool(Object? v) => v == true; DateTime? asDate(Object? v) { final s = asString(v); if (s == null || s.isEmpty) return null; - return DateTime.tryParse(s); + final parsed = DateTime.tryParse(s); + if (parsed == null) return null; + // A plain date ("2026-09-18") has no timezone of its own; `DateTime.tryParse` still + // tags it local, which silently shifts it by the machine's offset. Re-tag the same + // wall-clock fields as UTC so the date this API meant is the date callers get, on any + // machine — a full timestamp (already carrying "Z"/an offset) is left untouched. + if (parsed.isUtc) return parsed; + return DateTime.utc( + parsed.year, + parsed.month, + parsed.day, + parsed.hour, + parsed.minute, + parsed.second, + parsed.millisecond, + parsed.microsecond, + ); } /// A list of JSON objects; anything else (including null) becomes an empty list.