aboutsummaryrefslogtreecommitdiff
path: root/utils.py
diff options
context:
space:
mode:
authorAlban Gruin2017-01-20 14:40:19 +0100
committerAlban Gruin2017-01-20 14:40:19 +0100
commitdf2b69af6923aa9ef00e4e3070a28906b17593fc (patch)
treeb61ad3f816a362b4d41e58c7d8c5543fce67fee5 /utils.py
parenta4c9f9027c443a32ff3475dc292c7495f685b651 (diff)
Déduplication de la fonction get_week()
Diffstat (limited to 'utils.py')
-rw-r--r--utils.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/utils.py b/utils.py
new file mode 100644
index 0000000..5cc6648
--- /dev/null
+++ b/utils.py
@@ -0,0 +1,10 @@
+from django.utils import timezone
+
+import datetime
+
+def get_week(year, week):
+ start = timezone.make_aware(datetime.datetime.strptime(
+ "{0}-W{1:02d}-1".format(year, week), "%Y-W%W-%w"))
+ end = start + datetime.timedelta(weeks=1)
+
+ return start, end