From ce945c7428ad2d7ea852762ef9192bef1130885f Mon Sep 17 00:00:00 2001 From: Joshua Carp Date: Sat, 26 Sep 2015 20:16:03 -0400 Subject: [PATCH] Update built-in date filters. [Resolves #725] --- openfecwebapp/utils.py | 15 ++++++++++++++- templates/macros/filters/date.html | 16 ++++++---------- 2 files changed, 20 insertions(+), 11 deletions(-) diff --git a/openfecwebapp/utils.py b/openfecwebapp/utils.py index 50e5cec25..1003e0d09 100644 --- a/openfecwebapp/utils.py +++ b/openfecwebapp/utils.py @@ -73,6 +73,7 @@ def date_ranges(): """ today = datetime.date.today() quarter = math.floor((today.month - 1) / 3) + cycle = current_cycle() return { 'month': ( today.replace(day=1), @@ -91,5 +92,17 @@ def date_ranges(): day=calendar.monthrange(today.year, 12)[1], month=12, ), - ) + ), + 'cycle': ( + datetime.date( + year=cycle - 1, + month=1, + day=1, + ), + datetime.date( + year=cycle, + month=12, + day=calendar.monthrange(cycle, 12)[1], + ), + ), } diff --git a/templates/macros/filters/date.html b/templates/macros/filters/date.html index ac9151136..b10ee5233 100644 --- a/templates/macros/filters/date.html +++ b/templates/macros/filters/date.html @@ -5,20 +5,16 @@ {{ label }}