Opened 18 years ago

Closed 18 years ago

#2528 closed defect (fixed)

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

Reported by: django@… Owned by: Adrian Holovaty
Component: Template system Version: dev
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: no UI/UX: no

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 by Adrian Holovaty, 18 years ago

Resolution: fixed
Status: newclosed

(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