Skip to content

Instantly share code, notes, and snippets.

@amertkara
Last active August 29, 2015 14:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save amertkara/11008507 to your computer and use it in GitHub Desktop.
Save amertkara/11008507 to your computer and use it in GitHub Desktop.
def get_week_day(week_year, week_number, week_day=0):
""" For a given year and week_number, gets the day of that particular week
If week_year is 2014, week_number is 14 and week_day = 0,
it returns datetime.datetime(2014, 4, 6, 0, 0)
Args:
week_year (int)
week_number (int)
week_day (int): default is Sunday (0)
Returns (datetime):
The datetime objects that holds the date with h:m:s as 00:00:00
"""
return datetime.strptime(str(week_year) + "-" + str(week_number) + "-" + str(week_day) + " 00:00:00",
"%Y-%U-%w %H:%M:%S")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment