File size: 1,262 Bytes
a974944 bc959a0 a974944 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
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):
print(type(last_date_str))
print(last_date_str)
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
|