Opened 9 years ago

Closed 9 years ago

#2528 closed defect (fixed)

the time default filter is broken for midnight time value (always returns '')

Reported by: django@… Owned by: adrian
Component: Template system Version: master
Severity: normal Keywords: time filter midnight
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

Someone on the #django irc channel found this one.

>>> midnight = datetime.time(0,0)
>>> bool(midnight)
False
>>>

Midnight evaluates to false.
Here is the code for the 'time' filter from django.template.defaultfilters:

def time(value, arg=None):
    "Formats a time according to the given format"
    from django.utils.dateformat import time_format
    if not value:  ## BUG!
        return ''  ##
    if arg is None:
        arg = settings.TIME_FORMAT
    return time_format(value, arg)

due to the 'if not value:' midnight will never be rendered.

Change History (1)

comment:1 Changed 9 years ago by adrian

  • Resolution set to fixed
  • Status changed from new to closed

(In [3563]) Fixed #2528 -- Fixed 'time' template filter for midnight time value. Thanks, django@…

Note: See TracTickets for help on using tickets.
Back to Top