Fix of some timezone problems
Release Inventarsystem / release-docker (push) Successful in 3m18s

This commit is contained in:
2026-09-15 10:51:00 +02:00
parent 6311e7710a
commit a8f3907f34
2 changed files with 24 additions and 13 deletions
+19 -8
View File
@@ -7990,8 +7990,12 @@ def check_availability():
items_col = db['items']
# Collect potential conflicts (planned and active) for this day
same_day_start = datetime.datetime.combine(booking_date.date(), datetime.time.min)
same_day_end = datetime.datetime.combine(booking_date.date(), datetime.time.max)
same_day_start = datetime.datetime.combine(
booking_date.date(), datetime.time.min, tzinfo=ZoneInfo("Europe/Berlin")
)
same_day_end = datetime.datetime.combine(
booking_date.date(), datetime.time.max, tzinfo=ZoneInfo("Europe/Berlin")
)
candidates = list(ausleihungen.find({
'Item': item_id,
'Status': {'$in': ['planned', 'active']},
@@ -8009,6 +8013,8 @@ def check_availability():
if r_start is None:
r_start = same_day_start
# Overlap check: req_start < r_end and req_end > r_start
r_start = au.ensure_timezone_aware(r_start)
r_end = au.ensure_timezone_aware(r_end)
if req_start < r_end and req_end > r_start:
conflicts.append({
'id': str(r.get('_id')),
@@ -8223,16 +8229,19 @@ def add_booking():
period = request.form.get('period')
notes = request.form.get('notes', '')
# Parse dates as naive datetime objects
# Form timestamps represent local school time.
try:
# Simple datetime parsing without timezone
if start_date_str:
start_date = datetime.datetime.strptime(start_date_str, '%Y-%m-%d %H:%M:%S')
start_date = datetime.datetime.strptime(
start_date_str, '%Y-%m-%d %H:%M:%S'
).replace(tzinfo=ZoneInfo("Europe/Berlin"))
else:
return jsonify({'success': False, 'error': 'Missing start date'})
if end_date_str:
end_date = datetime.datetime.strptime(end_date_str, '%Y-%m-%d %H:%M:%S')
end_date = datetime.datetime.strptime(
end_date_str, '%Y-%m-%d %H:%M:%S'
).replace(tzinfo=ZoneInfo("Europe/Berlin"))
else:
end_date = None
@@ -11274,12 +11283,14 @@ def get_period_times(booking_date, period_num):
# Create datetime objects for start and end times
start_datetime = datetime.datetime.combine(
booking_date.date(),
datetime.time(start_hour, start_min)
datetime.time(start_hour, start_min),
tzinfo=ZoneInfo("Europe/Berlin")
)
end_datetime = datetime.datetime.combine(
booking_date.date(),
datetime.time(end_hour, end_min)
datetime.time(end_hour, end_min),
tzinfo=ZoneInfo("Europe/Berlin")
)
return {