Open Dieterbe opened 6 months ago
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.
i just checked how it works on web (wger.de)
<today>T15:47:01.701Z
<today>T17:47:01.701000+02:00
(different representation, but identical time)<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:
i will have a look if i can fix most or all of these.
for the first one, i have a fix in https://github.com/wger-project/flutter/pull/566
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