jtxBoard icon indicating copy to clipboard operation
jtxBoard copied to clipboard

[BUG] Incorrect sort order between TODO items with and without times in their due dates

Open Hawk777 opened this issue 2 years ago • 2 comments

Describe the bug I have two TODO items. One is due today, as a date. The other is due today at 00:00:00, as a datetime. I have jtx Board set to sort by due date ascending. The item due on a date is listed as “due today” while the item due on a datetime is listed as “overdue”; however, the “due today” item sorts earlier than the “overdue” item.

To Reproduce Steps to reproduce the behavior:

  1. Create two TODO items, item A due today as a date, item B due today at 00:00:00 as a datetime (I’m not sure if they have to be synced or if they can be created locally).
  2. Set the list sorting order to Due Ascending Then Priority Ascending (I’m not sure if the latter is necessary, but it’s how I have my list set up).
  3. Note that item A sorts before item B, but item A has the Due Today marker while item B has the Overdue marker (the markers are IMO correct, since an item due to day is due today, while an item due at midnight last night is now overdue by a handful of hours depending on what time of day one looks at it).

Expected behavior I would expect the sort order to agree with the marker metadata. Perhaps, for sorting purposes, items due on a date alone should be considered as being due at the very end of that day, rather than the very beginning.

Device and version:

  • Device: Motorola One 5G Ace
  • Android version: 11
  • jtx Board version: 2.04.07.ose
  • Downloaded from: f-Droid

Hawk777 avatar Jul 01 '23 17:07 Hawk777

Uff, I get the problem. Thanks @Hawk777 ! I'm just not sure if I will find an easy solution for that...

The date and time are stored as a timestamp. When you use date only then it's stored as the start of the day in the UTC timezone. When you choose the start of a day on midnight without specifying a timezone, the app will set the timestamp according to the system timezone. Depending if you're in a timezone with a negative or positive offset, the all-day entries would appear before it after the ones with a time.

As currently I'm using SQL queries for those searches, it is very efficient and fast. I'm afraid if I try to resolve this problem, I'd need to do everything in the code which would make it probably slower overall....

I'll be to think about if it's worth the change...

patrickunterwegs avatar Jul 01 '23 21:07 patrickunterwegs

It’s probably a bit of a corner case. I wonder if it’s possible to calculate a timestamp that will sort properly (something like “23:59:59 in the local timezone” maybe?) and use that for all-day VTODOs. If not, it’s probably a pretty niche corner case, so it might not be worth fixing.

Hawk777 avatar Jul 02 '23 16:07 Hawk777