Skip to content

Commit 880a451

Browse files
committed
Fix midnight end time bug
1 parent 2a6f23d commit 880a451

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

CHANGELOG.md

+9
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,15 @@
44

55
NOTE: potentially breaking changes are flagged with a 🧨 symbol.
66

7+
## 3.2.1
8+
9+
### Fixed
10+
11+
- `pyppms.booking.PpmsBooking.endtime_fromstr()` contained a bug where the
12+
end time of a booking finishing at midnight got wrongly assigning it to the
13+
*start* of the given day instead of the end. This is now fixed by setting the
14+
end time to the start of the following day.
15+
716
## 3.2.0
817

918
### Added

src/pyppms/booking.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"""Module representing bookings / reservations in PPMS."""
22

3-
from datetime import datetime
3+
from datetime import datetime, timedelta
44

55
from loguru import logger as log
66

@@ -144,6 +144,9 @@ def endtime_fromstr(self, time_str, date=None):
144144
second=0,
145145
microsecond=0,
146146
)
147+
if end.hour == 0 and end.minute == 0:
148+
end = end + timedelta(days=1)
149+
log.debug(f"Booking end is midnight, adjust date to {end}")
147150
self.endtime = end
148151
log.trace("New endtime: {}", self)
149152

0 commit comments

Comments
 (0)