Opened 14 years ago

Closed 14 years ago

#15263 closed New feature (fixed)

Make "now" templatetag accept locale formats.

Reported by: Daniel Roseman Owned by: nobody
Component: Template system Version: dev
Severity: Normal Keywords:
Cc: creecode@… 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

The documentation on the now tag claims that it acts like the date filter in accepting "DATE_FORMAT" as a shortcut to the locale's current date format. However, this is not the case:

>>> t=Template("""{% now "DATE_FORMAT" %}""")
>>> t.render(Context())
u'WedPMGMTE_February+0000RFebPMGMT'

Clearly the string is being interpreted as a literal format, instead of being translated to the locale's date format.

Attached patch fixes this by using the same logic as the date filter, including a regression test, and slightly tweaks the awkward wording in the docs.

Attachments (2)

now_tag.diff (2.9 KB ) - added by Daniel Roseman 14 years ago.
15263_now_tag.diff (2.7 KB ) - added by dmclain 14 years ago.
Sackcloth and ashes tour: Updated docs to fix patch errors and reflect new feature.

Download all attachments as: .zip

Change History (14)

by Daniel Roseman, 14 years ago

Attachment: now_tag.diff added

comment:1 by ersame, 14 years ago

Triage Stage: UnreviewedAccepted

The patch looks OK.

comment:2 by creecode@…, 14 years ago

Cc: creecode@… added
Has patch: unset

comment:3 by creecode@…, 14 years ago

Has patch: set

comment:4 by Ramiro Morales, 14 years ago

Triage Stage: AcceptedDesign decision needed

We introduced that extra paragraph about that non-existent interaction of the now tag with locale-dependent output formats in r14013 (fixes #13188) when moving the table of format specifiers from there to the date filter section.

We need to decide if we want to change the behavior of the tag to match the documentation (in which case the proposed patch can be reviewed, I haven't yet) or simply decide such change isn't worth or sensible and then treat this ticket as documentation bug.

Last edited 14 years ago by Ramiro Morales (previous) (diff)

comment:5 by Ramiro Morales, 14 years ago

In [15678]:

Reverted 'now' template tag documentation changes so it describes the real code implementation regarding (lack of) interaction with L10N machinery. Refs #15263. Thanks danielr for the report.

comment:6 by Ramiro Morales, 14 years ago

In [15679]:

[1.2.X] Reverted 'now' template tag documentation changes so it describes the real code implementation regarding (lack of) interaction with L10N machinery. Refs #15263. Thanks danielr for the report.

Backport of [15678] from trunk.

comment:7 by Ramiro Morales, 14 years ago

Triage Stage: Design decision neededAccepted

comment:8 by Łukasz Rekucki, 14 years ago

Severity: Normal
Summary: "now" templatetag doesn't accept locale formats, as docs claimMake "now" templatetag accept locale formats.
Type: New feature

With the change in the docs, it's now a feature request.

comment:9 by patchhammer, 14 years ago

Easy pickings: unset
Patch needs improvement: set

now_tag.diff fails to apply cleanly on to trunk

by dmclain, 14 years ago

Attachment: 15263_now_tag.diff added

Sackcloth and ashes tour: Updated docs to fix patch errors and reflect new feature.

comment:10 by dmclain, 14 years ago

Patch needs improvement: unset

comment:11 by Jannis Leidel, 14 years ago

Triage Stage: AcceptedReady for checkin

Other than adding a '.. versionadded:: 1.4' note for the docs this looks good to me.

comment:12 by Jannis Leidel, 14 years ago

Resolution: fixed
Status: newclosed

In [16172]:

Fixed #15263 -- Added support for format localization to the now template tag. Thanks to danielr and dmclain.

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