Django

Code

Ticket #2528 (closed: fixed)

Opened 2 years ago

Last modified 2 years ago

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

Reported by: django@dougma.com Assigned to: adrian
Milestone: Component: Template system
Version: SVN Keywords: time filter midnight
Cc: Triage Stage: Unreviewed
Has patch: 0 Needs documentation: 0
Needs tests: 0 Patch needs improvement: 0

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.

Attachments

Change History

08/12/06 00:09:13 changed by adrian

  • status changed from new to closed.
  • resolution set to fixed.

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


Add/Change #2528 (the time default filter is broken for midnight time value (always returns ''))




Change Properties
Action