diff options
author | Alban Gruin | 2017-02-05 16:12:51 +0100 |
---|---|---|
committer | Alban Gruin | 2017-02-05 16:12:51 +0100 |
commit | 706983d73996637148d640281b5a5e97f217b9b5 (patch) | |
tree | 287ee3507aba1e30cfb96edb2b309c7bfee31681 /utils.py | |
parent | 04162486502fee0fc6aa26aecd6919bde4cd3f73 (diff) |
Mise en commun de la fonction de récupération des semaines
Diffstat (limited to 'utils.py')
-rw-r--r-- | utils.py | 7 |
1 files changed, 7 insertions, 0 deletions
@@ -2,6 +2,13 @@ from django.utils import timezone import datetime +def get_current_or_next_week(): + year, week, day = timezone.now().isocalendar() + if day >= 6: + year, week, _ = (timezone.now() + datetime.timedelta(weeks=1)).isocalendar() + + return year, week + def get_week(year, week): start = timezone.make_aware(datetime.datetime.strptime( "{0}-W{1:02d}-1".format(year, week), "%Y-W%W-%w")) |