[Django] #32149: Fix date templatetag to print leading zero when using format character "y"

16 views
Skip to first unread message

Django

unread,
Oct 27, 2020, 12:42:53 AM10/27/20
to django-...@googlegroups.com
#32149: Fix date templatetag to print leading zero when using format character "y"
-------------------------------------+-------------------------------------
Reporter: Sam | Owner: nobody
Type: Bug | Status: new
Component: Template | Version: 3.1
system | Keywords: date templatetag
Severity: Normal | filter
Triage Stage: | Has patch: 1
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
When using the the dateformat of django with a date before 999 (or 99 and
9 for similar matters) and the format character "y" no leading zero will
be printed. This is not consistent with the way the python datetime module
and PHP handle that character "y" in format strings:

django (version 3.1):
{{{#!python
>>> import datetime
>>> from django.utils import dateformat
>>> dateformat.format(datetime.datetime(123, 4, 5, 6, 7), "y")
'3'
}}}

python (version 3.8):
{{{#!python
>>> import datetime
>>> datetime.datetime(123, 4, 5, 6, 7).strftime("%y")
'23'
}}}

php (version 7.4):
{{{#!php
echo date("y", strtotime("0123-04-05 06:07:00"))
23
}}}

I have a pull-request ready for this.

--
Ticket URL: <https://code.djangoproject.com/ticket/32149>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Oct 27, 2020, 1:58:15 AM10/27/20
to django-...@googlegroups.com
#32149: dateformat.y() doesn't support years < 1000.
-------------------------------------+-------------------------------------
Reporter: Sam | Owner: Sam
Type: Bug | Status: assigned
Component: Template system | Version: 3.1
Severity: Normal | Resolution:
Keywords: date templatetag | Triage Stage: Accepted
filter |
Has patch: 1 | Needs documentation: 1

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak):

* owner: nobody => Sam
* needs_docs: 0 => 1
* status: new => assigned
* stage: Unreviewed => Accepted


--
Ticket URL: <https://code.djangoproject.com/ticket/32149#comment:1>

Django

unread,
Nov 12, 2020, 6:47:56 AM11/12/20
to django-...@googlegroups.com
#32149: dateformat.y() doesn't support years < 1000.
-------------------------------------+-------------------------------------
Reporter: Sam | Owner: Sam
Type: Bug | Status: assigned
Component: Template system | Version: 3.1
Severity: Normal | Resolution:
Keywords: date templatetag | Triage Stage: Ready for
filter | checkin
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak):

* needs_docs: 1 => 0
* needs_tests: 1 => 0
* stage: Accepted => Ready for checkin


Comment:

[https://github.com/django/django/pull/13670 PR]

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

Django

unread,
Nov 12, 2020, 7:24:30 AM11/12/20
to django-...@googlegroups.com
#32149: dateformat.y() doesn't support years < 1000.
-------------------------------------+-------------------------------------
Reporter: Sam | Owner: Sam
Type: Bug | Status: closed

Component: Template system | Version: 3.1
Severity: Normal | Resolution: fixed

Keywords: date templatetag | Triage Stage: Ready for
filter | checkin
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak <felisiak.mariusz@…>):

* status: assigned => closed
* resolution: => fixed


Comment:

In [changeset:"895f6e49925ed0ae4bb96dc4d3af17fdc9c4846e" 895f6e49]:
{{{
#!CommitTicketReference repository=""
revision="895f6e49925ed0ae4bb96dc4d3af17fdc9c4846e"
Fixed #32149 -- Added support for years < 1000 to DateFormat.y().
}}}

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

Reply all
Reply to author
Forward
0 new messages