[Django] #26275: defaultfilter `date` incorrectly formats

6 views
Skip to first unread message

Django

unread,
Feb 24, 2016, 7:43:32 PM2/24/16
to django-...@googlegroups.com
#26275: defaultfilter `date` incorrectly formats
-------------------------------+------------------------------------
Reporter: mrigor | Owner: nobody
Type: Bug | Status: new
Component: Uncategorized | Version:
Severity: Normal | Keywords: 1.7.11 template filter
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------+------------------------------------
On 1.7.11

{{{#!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.

Django

unread,
Feb 25, 2016, 2:42:47 AM2/25/16
to django-...@googlegroups.com
#26275: defaultfilter `date` incorrectly formats
-------------------------------------+-------------------------------------
Reporter: mrigor | Owner: nobody
Type: | Status: new
Cleanup/optimization |
Component: Documentation | Version:
Severity: Normal | Resolution:
Keywords: 1.7.11 template | Triage Stage: Accepted
filter |
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by claudep):

* 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>

Django

unread,
Feb 26, 2016, 4:51:42 PM2/26/16
to django-...@googlegroups.com
#26275: defaultfilter `date` incorrectly formats
-------------------------------------+-------------------------------------
Reporter: mrigor | Owner: nobody

Type: | Status: new
Cleanup/optimization |
Component: Documentation | Version:
Severity: Normal | Resolution:
Keywords: 1.7.11 template | Triage Stage: Accepted
filter |
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------

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>

Django

unread,
Feb 26, 2016, 6:01:29 PM2/26/16
to django-...@googlegroups.com
#26275: defaultfilter `date` incorrectly formats
-------------------------------------+-------------------------------------
Reporter: mrigor | Owner: nobody

Type: | Status: new
Cleanup/optimization |
Component: Documentation | Version:
Severity: Normal | Resolution:
Keywords: 1.7.11 template | Triage Stage: Accepted
filter |
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by claudep):

Thanks, can you make it a pull request?

--
Ticket URL: <https://code.djangoproject.com/ticket/26275#comment:3>

Django

unread,
Feb 26, 2016, 7:33:52 PM2/26/16
to django-...@googlegroups.com
#26275: defaultfilter `date` incorrectly formats
-------------------------------------+-------------------------------------
Reporter: mrigor | Owner: nobody

Type: | Status: new
Cleanup/optimization |
Component: Documentation | Version:
Severity: Normal | Resolution:
Keywords: 1.7.11 template | Triage Stage: Accepted
filter |
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by inondle):

Yeah, made one here: https://github.com/django/django/pull/6210

--
Ticket URL: <https://code.djangoproject.com/ticket/26275#comment:4>

Django

unread,
Feb 26, 2016, 8:44:51 PM2/26/16
to django-...@googlegroups.com
#26275: defaultfilter `date` incorrectly formats
-------------------------------------+-------------------------------------
Reporter: mrigor | Owner: nobody
Type: | Status: new
Cleanup/optimization |
Component: Documentation | Version: master

Severity: Normal | Resolution:
Keywords: 1.7.11 template | Triage Stage: Accepted
filter |
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by charettes):

* has_patch: 0 => 1
* version: => master


--
Ticket URL: <https://code.djangoproject.com/ticket/26275#comment:5>

Django

unread,
Feb 27, 2016, 7:50:05 AM2/27/16
to django-...@googlegroups.com
#26275: Clarify the meaning of the `date` filter's 'o' formatter
-------------------------------------+-------------------------------------
Reporter: mrigor | Owner: nobody

Type: | Status: new
Cleanup/optimization |
Component: Documentation | Version: master
Severity: Normal | Resolution:
Keywords: 1.7.11 template | Triage Stage: Accepted
filter |
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------

--
Ticket URL: <https://code.djangoproject.com/ticket/26275#comment:6>

Django

unread,
Feb 27, 2016, 8:07:19 AM2/27/16
to django-...@googlegroups.com
#26275: Clarify the meaning of the `date` filter's 'o' formatter
-------------------------------------+-------------------------------------
Reporter: mrigor | Owner: nobody
Type: | Status: closed

Cleanup/optimization |
Component: Documentation | Version: master
Severity: Normal | Resolution: fixed

Keywords: 1.7.11 template | Triage Stage: Accepted
filter |
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Tim Graham <timograham@…>):

* 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>

Django

unread,
Feb 27, 2016, 8:07:59 AM2/27/16
to django-...@googlegroups.com
#26275: Clarify the meaning of the `date` filter's 'o' formatter
-------------------------------------+-------------------------------------
Reporter: mrigor | Owner: nobody

Type: | Status: closed
Cleanup/optimization |
Component: Documentation | Version: master
Severity: Normal | Resolution: fixed
Keywords: 1.7.11 template | Triage Stage: Accepted
filter |
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------

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>

Reply all
Reply to author
Forward
0 new messages