Use current time as the day end/start, not 00:00, so today does not skew averages if you sleep through 00:00
Your weekly average may be calculated as 1/7 less if it's 00:01 and you just woke up, having slept for one minute today.
To avoid that, you could add the sleeps from the latter 23:59 of the day before the week. That is, do as if the time zone was (local time)+23:59, and the day had started on 00:01 the previous day and is ending right now.
Anki probably does this for its graphs: https://docs.ankiweb.net/preferences.html#scheduler
Could you please write a concrete example where you think the current code is not correct?
https://github.com/vmiklos/plees-tracker/blob/aad0bfec96fcfb5ff08c02723f921553aec68cb1/app/src/main/java/hu/vmiklos/plees_tracker/DataModel.kt#L429-L445
is the current code, i.e. the assumption is that a sleep belongs to the day where it ends, since most people may go to bed before or after midnight, but definitely they wake up after midnight.
So in general, if something is inaccurate, I would guess we book more for "this week" (i.e. you wake up at 0:01 and then this counts for today, not yesterday), but your concern seems to be the opposite, so it would be good to talk about a specific example.
I wake up multiple times a night.
Hm, so let's say you plan to sleep from 22:00 to 6:00, but in practice you have a 22:00 -> 22:55, then a 23:00 -> 6:00 item and you would like plees-tracker to consider both a sleep that belongs to the next day, similar to having a single 22:00 -> 6:00 item?
Right. But I didn't know how it actually worked, so I can't fit it with your algorithm.
Maybe it could find the one or two longest awake times, like longer than 3-6 hours or so (I haven't thought that though).