You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
today, at some time, e.g. 4 PM, log an ingredient to the plan (using the mobile app)
the POST request to https://wger.de/api/v2/nutritiondiary/ uses datetime: <today>T00:00:00.000 , that same api call has a response including datetime: <today>T00:00:00+02:00
in nutrition.dart, fetchAndSetLogs(),
the api returns json such as {id: 13499, plan: 92895, meal: null, ingredient: 146034, weight_unit: null, datetime: <today>T00:00:00+02:00, amount: 100.00}
the decoded datetime (after Log.fromJson(logData); ) is <yesterday> 22:00:00.000Z
Expected results:
i would expect accurate time to get logged, and my logged items to show up for the correct day
Actual results:
both time and timezone get altered, logged items are classified under the wrong day
The text was updated successfully, but these errors were encountered:
i will do some more digging and experimentation. hopefully this just needs some small tweaks in dart, and not in django.
i hope the timezone handling is django is solid.
nutrition entry has a datetime field (on flutter, you only chose a date, not time)
POST request has <today>T15:47:01.701Z
POST response has <today>T17:47:01.701000+02:00 (different representation, but identical time)
nutritiondiary api call returns <today>T17:47:01.701000+02:00
so this is all pretty correct.
with flutter, we encode (to submit to the api) using _$LogToJson(Log instance) uses instance.datetime.toIso8601String() which says:
The format is yyyy-MM-ddTHH:mm:ss.mmmuuuZ for UTC time, and yyyy-MM-ddTHH:mm:ss.mmmuuu (no trailing "Z") for local/non-UTC time
and we decode what we got from the api in _$LogFromJson using DateTime.parse which supports localtime and zulu time properly.
it seems with flutter, we have these issues:
the posted time is nonsensical, and doesn't allow for tweaking the time
while the part of encoding/decoding actually seems to work fine.
However, the flutter app acts as if we are in UTC, effectively ignoring the user's timezone (even when the data is technically correct, just represented differently), thereby attributing events to the wrong days
i will have a look if i can fix most or all of these.
for the 2nd one, not sure yet what's the best way to fix it. but at least for EU users the first fix alone solves the problem in practice (unless you log foods shortly after midnight :-)
Steps to Reproduce
be in a timezone that is not UTC. I am in UTC+2
<today>T00:00:00.000
, that same api call has a response including datetime:<today>T00:00:00+02:00
{id: 13499, plan: 92895, meal: null, ingredient: 146034, weight_unit: null, datetime: <today>T00:00:00+02:00, amount: 100.00}
<yesterday> 22:00:00.000Z
Expected results:
i would expect accurate time to get logged, and my logged items to show up for the correct day
Actual results:
both time and timezone get altered, logged items are classified under the wrong day
The text was updated successfully, but these errors were encountered: