#26275 closed Cleanup/optimization (fixed)
Clarify the meaning of the `date` filter's 'o' formatter
Reported by: | Igor Rashnitsov | Owned by: | nobody |
---|---|---|---|
Component: | Documentation | Version: | dev |
Severity: | Normal | Keywords: | 1.7.11 template filter |
Cc: | Triage Stage: | Accepted | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | yes | UI/UX: | no |
Description
On 1.7.11
>>> from datetime import datetime >>> from django.template.defaultfilters import date >>> date(datetime(2016, 1, 1, 0), 'F o') u'January 2015'
(instead of 'January 2016')
Settings:
USE_TZ = False TIME_ZONE = 'UTC' LANGUAGE_CODE = 'en-us' USE_I18N = True USE_L10N = True
Change History (8)
comment:1 by , 9 years ago
Component: | Uncategorized → Documentation |
---|---|
Triage Stage: | Unreviewed → Accepted |
Type: | Bug → Cleanup/optimization |
comment:2 by , 9 years ago
I added a note about the meaning of the o
specifier. I added it to my django fork here
https://github.com/inondle/django/blob/master/docs/ref/templates/builtins.txt#L1296
Does that look good or are there any improvements I could make?
comment:5 by , 9 years ago
Has patch: | set |
---|---|
Version: | → master |
comment:6 by , 9 years ago
Summary: | defaultfilter `date` incorrectly formats → Clarify the meaning of the `date` filter's 'o' formatter |
---|
Note:
See TracTickets
for help on using tickets.
I think that's the problem of your format string. Basically, you are asking: "Show me the month of that date (F) and then the year corresponding to the ISO week for that date (o)". So you are juxtaposing two values which don't make sense together. You should use 'Y' for the year in this case.
We could add a note in the documentation for
o
(at least "See alsoY
"), because people might browse the list of formatters (https://docs.djangoproject.com/en/1.9/ref/templates/builtins/#date) and stop at the first letter that match their initial intention, without understanding the real meaning ofo
.