{{{#!python
>>> 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:
{{{#!python
USE_TZ = False
TIME_ZONE = 'UTC'
LANGUAGE_CODE = 'en-us'
USE_I18N = True
USE_L10N = True
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/26275>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* needs_better_patch: => 0
* component: Uncategorized => Documentation
* needs_tests: => 0
* needs_docs: => 0
* type: Bug => Cleanup/optimization
* stage: Unreviewed => Accepted
Comment:
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 also
`Y`"), 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 of `o`.
--
Ticket URL: <https://code.djangoproject.com/ticket/26275#comment:1>
Comment (by inondle):
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?
--
Ticket URL: <https://code.djangoproject.com/ticket/26275#comment:2>
Comment (by claudep):
Thanks, can you make it a pull request?
--
Ticket URL: <https://code.djangoproject.com/ticket/26275#comment:3>
Comment (by inondle):
Yeah, made one here: https://github.com/django/django/pull/6210
--
Ticket URL: <https://code.djangoproject.com/ticket/26275#comment:4>
* has_patch: 0 => 1
* version: => master
--
Ticket URL: <https://code.djangoproject.com/ticket/26275#comment:5>
--
Ticket URL: <https://code.djangoproject.com/ticket/26275#comment:6>
* status: new => closed
* resolution: => fixed
Comment:
In [changeset:"5fb9756eba01237cc0e550da689b9b79c51c96ed" 5fb9756e]:
{{{
#!CommitTicketReference repository=""
revision="5fb9756eba01237cc0e550da689b9b79c51c96ed"
Fixed #26275 -- Noted difference between o and Y date format chars.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/26275#comment:7>
Comment (by Tim Graham <timograham@…>):
In [changeset:"e96cdc6f99923621f543751d4cc0fddef1514422" e96cdc6]:
{{{
#!CommitTicketReference repository=""
revision="e96cdc6f99923621f543751d4cc0fddef1514422"
[1.9.x] Fixed #26275 -- Noted difference between o and Y date format
chars.
Backport of 5fb9756eba01237cc0e550da689b9b79c51c96ed from master
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/26275#comment:8>