Code

Opened 20 months ago

Closed 20 months ago

Last modified 20 months ago

#19370 closed Bug (fixed)

date filter returns empty string for midnight

Reported by: dbrgn 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.

Attachments (0)

Change History (4)

comment:1 Changed 20 months ago by dbrgn

  • Has patch set
  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

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 Changed 20 months ago by claudep

  • Triage Stage changed from Unreviewed to Ready for checkin

comment:3 Changed 20 months ago by Claude Paroz <claude@…>

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

In c10aaa70a4cc2e567dc29953f33f0a4219717d61:

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

comment:4 Changed 20 months ago by Claude Paroz <claude@…>

In 5509eb862668ebeadd52248e2af124dfce2cce72:

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

Backport of c10aaa70a from master.

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.