albertvaka / bettercounter

A daily counter to track habits
GNU General Public License v2.0
125 stars 17 forks source link

Wrong averaging in leap year February #50

Closed l3u closed 6 months ago

l3u commented 6 months ago

Hi!

First of all thanks for this nice app :-)

I think there's an issue with the "average per month" calculation, and it seems like it has something to do with the current leap year:

Screenshot_Feb_2024

41 divided by 29 is 1.41..., not 1.32…!

The months before, the average was always correct, e.g. Jan 23: 42 times, 31 days → 1.35, Dec 23: 54 times, 31 days → 1.74, Nov 23: 32 / 30 → 1.07 and so on.

Seems like BetterCounter supposes a leap February has 31 days, at least 41 / 1.32 ≈ 31.

Cheers, Tobias

l3u commented 6 months ago

Here's the respective exported dataset: bettercounter-export.csv

albertvaka commented 6 months ago

It turns out it had nothing to do with the leap years, but the calculation was wrong (it would count until today instead of until the end of the month, if the last count was the previous month). Thanks for reporting it! I'll publish a fix now :smile:

l3u commented 6 months ago

Well, then, this actually was coincidence ;-) Thanks a lot for the fix in no time!