Use first day of next month as upper bound for donations #8

Closed
rluetzner wants to merge 1 commit from refs/pull/8/head into develop
rluetzner commented 2023-05-31 12:56:06 +02:00 (Migrated from codeberg.org)

This fixes an issue where donations for the last day of the month were
not displayed. This was due to the upper bound being the last day of the
month, but at 00:00.

The right way to do it is to check if the date is less than the first
day of next month at 00:00. This is a bit tricky. Go/Hugo offers an
AddDate function, which I almost used. However, because today is the
31st of May and June doesn't have 31 days, adding a month flipped over
to July, which would mess up our table.

I therefore resorted to a more basic implementation, which is commented
in the template itself. I almost forgot the modulo operation which would
have caused issues in December.

I'm not totally happy with this solution, because it comes with a lot of
moving parts and it's possible that I messed up or forgot another edge
case, but it's the best I can come up with right now.

This fixes an issue where donations for the last day of the month were not displayed. This was due to the upper bound being the last day of the month, but at 00:00. The right way to do it is to check if the date is less than the first day of next month at 00:00. This is a bit tricky. Go/Hugo offers an `AddDate` function, which I almost used. However, because today is the 31st of May and June doesn't have 31 days, adding a month flipped over to July, which would mess up our table. I therefore resorted to a more basic implementation, which is commented in the template itself. I almost forgot the modulo operation which would have caused issues in December. I'm not totally happy with this solution, because it comes with a lot of moving parts and it's possible that I messed up or forgot another edge case, but it's the best I can come up with right now.
Tealk commented 2023-05-31 14:03:33 +02:00 (Migrated from codeberg.org)

Thanks for the suggestion, here I could shorten the whole thing to one line 😅
279ae5a437

Thanks for the suggestion, here I could shorten the whole thing to one line 😅 279ae5a437ffc9b1c0a814edb86fea1606ad508d

Pull request closed

Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
RollenspielMonster/website!8
No description provided.