[Django] #20693: Add timezone support to built-in time template filter

6 views
Skip to first unread message

Django

unread,
Jul 2, 2013, 3:37:28 PM7/2/13
to django-...@googlegroups.com
#20693: Add timezone support to built-in time template filter
---------------------------------+--------------------
Reporter: warren@… | Owner: nobody
Type: New feature | Status: new
Component: Template system | Version: 1.5
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
---------------------------------+--------------------
Currently, the built-in time template filter does not support timezone,
even if timezone information is present on the time or datetime object
that is passed to it.

The built-in date filter DOES support timezone if passed a datetime
object, so this is often used as a workaround. However, when attempting to
use the DATE_FORMAT and TIME_FORMAT settings in conjunction with naked {{
value|date }} and {{ value|time }} template expressions to get consistent
date and time formatting across a site, the lack of timezone support in
the time filter is a problem if timezone information needs to be displayed
after the time.

There is a discussion of this issue on the Django Developers list:
https://groups.google.com/forum/#!topic/django-developers/r-7dMZROTs4

The consensus so far seems to be to modify the
django.utils.dateformat.TimeFormat class so that it has similar timezone
support for datetime objects as does the DateFormat class in the same
module. Since DateFormat is a subclass of TimeFormat, it is likely that
the timezone support methods can just be moved from DateFormat into
TimeFormat, along with the __init__() method.

Some modification to the methods will need to occur to account for the
case where a time object (not a datetime object) is passed to a filter
with a timezone-related format specifier. It was decided in the discussion
that the behavior in this case should be that the format method will
return an empty string.

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

Django

unread,
Jul 2, 2013, 3:38:56 PM7/2/13
to django-...@googlegroups.com
#20693: Add timezone support to built-in time template filter
---------------------------------+--------------------------------------
Reporter: warren@… | Owner: wsmith323
Type: New feature | Status: assigned

Component: Template system | Version: 1.5
Severity: Normal | Resolution:
Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

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

* status: new => assigned
* needs_better_patch: => 0
* owner: nobody => wsmith323
* needs_tests: => 0
* needs_docs: => 0


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

Django

unread,
Jul 2, 2013, 3:40:06 PM7/2/13
to django-...@googlegroups.com
#20693: Add timezone support to built-in time template filter
---------------------------------+--------------------------------------
Reporter: warren@… | Owner: wsmith323
Type: New feature | Status: assigned
Component: Template system | Version: 1.5
Severity: Normal | Resolution:
Keywords: | Triage Stage: Unreviewed

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

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

Comment (by wsmith323):

I have the code modified. I'm working on adding tests and tweaking the
documentation.

--
Ticket URL: <https://code.djangoproject.com/ticket/20693#comment:2>

Django

unread,
Jul 3, 2013, 1:40:41 PM7/3/13
to django-...@googlegroups.com
#20693: Add timezone support to built-in time filter

---------------------------------+--------------------------------------
Reporter: warren@… | Owner: wsmith323
Type: New feature | Status: assigned
Component: Template system | Version: 1.5
Severity: Normal | Resolution:
Keywords: | Triage Stage: Unreviewed

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

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

Comment (by wsmith323):

I've added tests and have them all passing under SQLite. I don't think I
need to test under additional dbs, since this is primarily a template
change.

However, since the generic django time formatting behavior is changing
slightly (assumption on my part given the location of my changes), I
suppose it is possible that there might be some weird db-specific
regression or subtle unexpected behavior change that will bite folks.

I've submitted https://github.com/django/django/pull/1327.

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

Django

unread,
Jul 3, 2013, 1:44:47 PM7/3/13
to django-...@googlegroups.com
#20693: Add timezone support to built-in time filter
---------------------------------+--------------------------------------
Reporter: warren@… | Owner: wsmith323
Type: New feature | Status: assigned
Component: Template system | Version: 1.5
Severity: Normal | Resolution:
Keywords: | Triage Stage: Unreviewed
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

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

* has_patch: 0 => 1


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

Django

unread,
Jul 3, 2013, 1:48:31 PM7/3/13
to django-...@googlegroups.com
#20693: Add timezone support to built-in time filter
---------------------------------+-------------------------------------

Reporter: warren@… | Owner: wsmith323
Type: New feature | Status: assigned
Component: Template system | Version: 1.5
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted

Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

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

* stage: Unreviewed => Accepted


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

Django

unread,
Jul 3, 2013, 1:49:19 PM7/3/13
to django-...@googlegroups.com
#20693: Add timezone support to built-in time filter
---------------------------------+-------------------------------------
Reporter: warren@… | Owner: wsmith323
Type: New feature | Status: assigned
Component: Template system | Version: master

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

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

* version: 1.5 => master


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

Django

unread,
Jul 29, 2013, 10:47:56 AM7/29/13
to django-...@googlegroups.com
#20693: Add timezone support to built-in time filter
-------------------------------------+-------------------------------------

Reporter: warren@… | Owner: wsmith323
Type: New feature | Status: assigned
Component: Template system | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Ready for
Has patch: 1 | checkin
Needs tests: 0 | Needs documentation: 0
Easy pickings: 0 | Patch needs improvement: 0
| UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by estebistec):

* stage: Accepted => Ready for checkin


Comment:

Ready for checkin/final review by core dev.

--
Ticket URL: <https://code.djangoproject.com/ticket/20693#comment:7>

Django

unread,
Aug 26, 2013, 5:20:29 PM8/26/13
to django-...@googlegroups.com
#20693: Add timezone support to built-in time filter
-------------------------------------+-------------------------------------
Reporter: warren@… | Owner: wsmith323
Type: New feature | Status: assigned
Component: Template system | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Ready for
Has patch: 1 | checkin
Needs tests: 0 | Needs documentation: 0
Easy pickings: 0 | Patch needs improvement: 0
| UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by anonymous):

I have re-based my local branch so the pull-request looks clean against
the current master. Not sure what else to do.

--
Ticket URL: <https://code.djangoproject.com/ticket/20693#comment:8>

Django

unread,
Aug 26, 2013, 6:09:35 PM8/26/13
to django-...@googlegroups.com
#20693: Add timezone support to built-in time filter
-------------------------------------+-------------------------------------
Reporter: warren@… | Owner: wsmith323
Type: New feature | Status: closed

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

Keywords: | Triage Stage: Ready for
Has patch: 1 | checkin
Needs tests: 0 | Needs documentation: 0
Easy pickings: 0 | Patch needs improvement: 0
| UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Warren Smith <warren@…>):

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


Comment:

In [changeset:"dd3a883894a219bc6c69e556c694734ab82b33e9"]:
{{{
#!CommitTicketReference repository=""
revision="dd3a883894a219bc6c69e556c694734ab82b33e9"
Fixed #20693 -- Add timezone support to built-in time filter.

Modified django.utils.dateformat module, moving __init__() method and
timezone-related format methods from DateFormat class to TimeFormat
base class. Modified timezone-related format methods to return an
empty string when timezone is inappropriate for input value.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/20693#comment:9>

Django

unread,
Sep 22, 2013, 2:44:26 PM9/22/13
to django-...@googlegroups.com
#20693: Add timezone support to built-in time filter
-------------------------------------+-------------------------------------
Reporter: warren@… | Owner: wsmith323
Type: New feature | Status: closed
Component: Template system | Version: master
Severity: Normal | Resolution: fixed
Keywords: | Triage Stage: Ready for
Has patch: 1 | checkin
Needs tests: 0 | Needs documentation: 0
Easy pickings: 0 | Patch needs improvement: 0
| UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Ramiro Morales <cramm0@…>):

In [changeset:"bebb449ac334d7365a015b34b9c894dc4bf63f7f"]:
{{{
#!CommitTicketReference repository=""
revision="bebb449ac334d7365a015b34b9c894dc4bf63f7f"
Added docs for changes in commit dd3a883894.

Refs #20693.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/20693#comment:10>

Reply all
Reply to author
Forward
0 new messages