Last active
September 6, 2017 22:48
-
-
Save liladas/4c8a2d441bd9443db305d93a257ab002 to your computer and use it in GitHub Desktop.
datetime from isoweekday
This file contains hidden or 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_day_of_week(isoweekday): | |
base = datetime.datetime.today() | |
return [d for d in [base - datetime.timedelta(days=x) for x in range(0, 7)] if d.isoweekday()==isoweekday][0] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment