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.