[31988f42] Feat: Added lunch break (12:00-12:30) and 2026 Bavarian holidays to slot finding logic
This commit is contained in:
@@ -102,8 +102,25 @@ def find_slots(start, view, interval):
|
|||||||
"""
|
"""
|
||||||
Parses availability string: '0'=Free, '2'=Busy.
|
Parses availability string: '0'=Free, '2'=Busy.
|
||||||
Returns 2 free slots (start times) within business hours (09:00 - 16:30),
|
Returns 2 free slots (start times) within business hours (09:00 - 16:30),
|
||||||
excluding weekends (Sat/Sun), with approx. 3 hours distance between them.
|
excluding weekends (Sat/Sun), lunch breaks, and holidays.
|
||||||
"""
|
"""
|
||||||
|
# Hardcoded Bavarian Holidays for 2026 (Common in Munich)
|
||||||
|
HOLIDAYS_2026 = {
|
||||||
|
(1, 1), # Neujahr
|
||||||
|
(1, 6), # Heilige Drei Könige
|
||||||
|
(4, 3), # Karfreitag
|
||||||
|
(4, 6), # Ostermontag
|
||||||
|
(5, 1), # Maifeiertag
|
||||||
|
(5, 14), # Christi Himmelfahrt
|
||||||
|
(5, 25), # Pfingstmontag
|
||||||
|
(6, 4), # Fronleichnam
|
||||||
|
(8, 15), # Mariä Himmelfahrt
|
||||||
|
(10, 3), # Tag der Deutschen Einheit
|
||||||
|
(11, 1), # Allerheiligen
|
||||||
|
(12, 25), # 1. Weihnachtstag
|
||||||
|
(12, 26) # 2. Weihnachtstag
|
||||||
|
}
|
||||||
|
|
||||||
slots = []
|
slots = []
|
||||||
first_slot = None
|
first_slot = None
|
||||||
|
|
||||||
@@ -116,7 +133,15 @@ def find_slots(start, view, interval):
|
|||||||
# 1. Mon-Fri only
|
# 1. Mon-Fri only
|
||||||
# 2. Business hours (09:00 - 16:30)
|
# 2. Business hours (09:00 - 16:30)
|
||||||
# 3. Future only
|
# 3. Future only
|
||||||
if slot_time.weekday() < 5 and (9 <= slot_time.hour < 17) and slot_time > datetime.now(TZ_BERLIN):
|
# 4. No Holidays (Bavaria)
|
||||||
|
# 5. Lunch break (12:00 - 12:30)
|
||||||
|
|
||||||
|
is_holiday = (slot_time.month, slot_time.day) in HOLIDAYS_2026
|
||||||
|
is_weekend = slot_time.weekday() >= 5
|
||||||
|
is_lunch = 12 == slot_time.hour and slot_time.minute < 30
|
||||||
|
is_business_hours = 9 <= slot_time.hour < 17
|
||||||
|
|
||||||
|
if not is_weekend and not is_holiday and not is_lunch and is_business_hours and slot_time > datetime.now(TZ_BERLIN):
|
||||||
# Max start time 16:30
|
# Max start time 16:30
|
||||||
if slot_time.hour == 16 and slot_time.minute > 30:
|
if slot_time.hour == 16 and slot_time.minute > 30:
|
||||||
continue
|
continue
|
||||||
|
|||||||
Reference in New Issue
Block a user