Created
January 13, 2021 15:29
-
-
Save dg1an3/ec732665bf5071e8185a33b48da4884d to your computer and use it in GitHub Desktop.
python code to create a random series of session dates
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def date_from_workday(workday_num): | |
return datetime.strptime(f"2021-W{workday_num//5+1}-{workday_num%5+1}", '%Y-W%W-%w') | |
def generate_session_dates(session_count=15, start_workday=None): | |
session_dates = [] | |
session_workday = start_workday if start_workday else randint(0,200) | |
for n in range(session_count): | |
session_dates.append(date_from_workday(session_workday)) | |
session_workday += 1 if randint(0,5) else 2 | |
return session_dates |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment