aardappel / procrastitracker

a Windows time tracking application
http://strlen.com/procrastitracker/
483 stars 53 forks source link

Quick Sets #72

Open wino45 opened 3 years ago

wino45 commented 3 years ago

Some of the Quick Sets are not working today (Jan 8): 14 days, 30 days,.. All of them that go back to year 2020.

aardappel commented 3 years ago

Yup.. looks like it doesn't manage to cross the year boundary..

aardappel commented 3 years ago

Ok, this is going to be somewhat hard to fix:

https://github.com/aardappel/procrastitracker/blob/6ad3abffd62c70401625920a40c52136ec8970e6/src/day.h#L2-L8

Internally, a "day" is number derived from the date, but it doesn't count 365 days in the year, it does 512, such that the day has a fixed number of bits in the date representation.

So the problem with the "14 days quick set" on Jan 8 is that it reaches into 6 unused days in the previous year.

This is frankly a bad design, but is hard to fix now, because these day numbers are stored in the database.

So there's two solutions:

  1. Bump to a new version in the database format, where these day numbers are contiguous. Convert from the old representation on load.
  2. Leave this format as is, but write a function for "quick set" that knows how many days to go into the past for to account for the blank days in between months and years.

2 is a lot simpler, 1 is cleaner..