Opened 12 years ago

Closed 12 years ago

Last modified 12 years ago

#19370 closed Bug (fixed)

date filter returns empty string for midnight

Reported by: Danilo Bargen Owned by: nobody
Component: Template system Version: 1.4
Severity: Normal Keywords:
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Python considers midnight (datetime.time(0, 0)) to be False. The date template filter stumbles over this.

When using {{ midnight|date:"H:i" }}, Django returns an empty string.

See http://bugs.python.org/issue13936 for discussion about the bug.

I'll post a pull request with the fix on Github in a short while.

Change History (4)

comment:1 by Danilo Bargen, 12 years ago

Has patch: set

Pull request is here: https://github.com/django/django/pull/558

This is already fixed in the |time filter, but not in the |date filter which can also be used to format times.

Regression tests are provided.

comment:2 by Claude Paroz, 12 years ago

Triage Stage: UnreviewedReady for checkin

comment:3 by Claude Paroz <claude@…>, 12 years ago

Resolution: fixed
Status: newclosed

In c10aaa70a4cc2e567dc29953f33f0a4219717d61:

Fixed #19370 -- Made date filter properly handle midnight value

comment:4 by Claude Paroz <claude@…>, 12 years ago

In 5509eb862668ebeadd52248e2af124dfce2cce72:

[1.5.x] Fixed #19370 -- Made date filter properly handle midnight value

Backport of c10aaa70a from master.

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