From bc51e00a0bb544ffdf5c249dbaf26384730f5e6a Mon Sep 17 00:00:00 2001 From: Erik Stein Date: Wed, 1 Feb 2017 13:03:08 +0100 Subject: [PATCH] dates module. --- utils/dateformat.py | 3 ++- utils/dates.py | 11 +++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 utils/dates.py diff --git a/utils/dateformat.py b/utils/dateformat.py index 240dd24..68512c2 100644 --- a/utils/dateformat.py +++ b/utils/dateformat.py @@ -6,6 +6,7 @@ Extends django.utils.dateformat Adds date and time range functions # TODO Describe custom formats +# TODO Use Django's names 'MONTH_DAY_FORMAT' and 'YEAR_MONTH_FORMAT' """ @@ -173,7 +174,7 @@ def format_timespan_range(timespan_object, force_wholeday=False, variant=DEFAULT if (timespan_object.is_multiday() or not timespan_object.start_time or force_wholeday): - # Don't show timespan + # Don't show times return rv else: rv = _("%(daterange)s %(timespan)s Uhr") % { diff --git a/utils/dates.py b/utils/dates.py new file mode 100644 index 0000000..9fb760e --- /dev/null +++ b/utils/dates.py @@ -0,0 +1,11 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals +# Erik Stein , 2016 + + +import calendar + + +def get_last_of_month(d): + day = calendar.monthrange(d.year, d.month)[1] + return d.replace(day=day)