diff options
author | Christian Pointner <equinox@helsinki.at> | 2016-04-15 18:41:03 (GMT) |
---|---|---|
committer | Christian Pointner <equinox@helsinki.at> | 2016-04-15 18:41:03 (GMT) |
commit | 17f110df8c14ea258d9227d08471a4a82bfa4657 (patch) | |
tree | f2aaf3e4bbf132fa3d0fbbbafca88a420f8225a7 /program/utils.py | |
parent | 1d521e1c65babb8412b4959bd476596e0aa36aa6 (diff) | |
parent | 179a462bf561dc0cb4d19133e7e3684055278296 (diff) |
merged master into stable after new deployment
Diffstat (limited to 'program/utils.py')
-rw-r--r-- | program/utils.py | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/program/utils.py b/program/utils.py index 9a086da..587e83d 100644 --- a/program/utils.py +++ b/program/utils.py @@ -3,6 +3,7 @@ from django.conf import settings import json import urllib from os.path import join +from datetime import datetime, date, timedelta def get_automation_id_choices(): @@ -26,3 +27,11 @@ def get_automation_id_choices(): shows = [(s['id'], s['title']) for s in shows_list] return shows + + +def tofirstdayinisoweek(year, week): + # http://stackoverflow.com/questions/5882405/get-date-from-iso-week-number-in-python + ret = datetime.strptime('%04d-%02d-1' % (year, week), '%Y-%W-%w') + if date(year, 1, 4).isoweekday() > 4: + ret -= timedelta(days=7) + return ret |