from datetime import datetime, timedelta team_members = ["Yiannis", "Anastasia", "Bulat", "Thomas", "Sanika"] def count_weekdays(start_date, end_date, target_weekdays): total_days = (end_date - start_date).days + 1 count = 0 for day in range(total_days): current_day = start_date + timedelta(days=day) if current_day.weekday() in target_weekdays: count += 1 return count def get_next_standup_taker(last_standup_taker, last_date_str, force_standup_taker=None, current_date=None): today = current_date if current_date else datetime.now().date() today_str = today.strftime("%Y-%m-%d") weekday = today.weekday() if weekday not in [1, 3]: return "Today is not a stand-up day.", today_str if force_standup_taker: return force_standup_taker, today_str last_date = datetime.strptime(last_date_str, "%Y-%m-%d").date() elapsed_days = count_weekdays(last_date, today, [1, 3]) last_index = team_members.index(last_standup_taker) next_index = (last_index + elapsed_days - 1) % len(team_members) next_standup_taker = team_members[next_index] return next_standup_taker, today_str