heikkilevanto / beertracker

Simple script to track the beers I drink
GNU General Public License v2.0
2 stars 1 forks source link

Posting a beer after midnight gets on te wrong date #170

Closed heikkilevanto closed 3 years ago

heikkilevanto commented 3 years ago

I filed a beer - actually a wine - on the night of 24-Dec, bit past midnight. It got filed with timestamp "2020-12-26 00:17:15;" and effdate "2020-12-25", both off by one day.

heikkilevanto commented 3 years ago

Probably related to the new feature of enabling date/time entry

heikkilevanto commented 3 years ago

Confirmed, but I am too tired to hunt it down now.

heikkilevanto commented 3 years ago

Enabled the commented-out debug prints on the dates, and filed a wine after midnight: BEFOR D='' T='' S='2020-12-27 00:19:20' E='Sat; 2020-12-26' AFTER D='2020-12-27' T='00:19:20' S='2020-12-28 00:19:20; Sun' E='2020-12-27'

On the second line, D is right, but S has a wrong date and weekday, and E date is wrong.

heikkilevanto commented 3 years ago

The code was clearly wrong. No need to check if we are past midnight, just take the date of now - 8hrs, and you have the effdate. The wkday comes the same way. Committed a change to that effect, it works now, past midnight. Test tomorrow and close if ok.

heikkilevanto commented 3 years ago

Fixed again, using 'date' to get the effdate right, even when entering date/time.