#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. -- You received this message because you are subscribed to the Google Groups "Django updates" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-updates+unsubscr...@googlegroups.com. To post to this group, send email to django-updates@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/064.2984f84933c1c22f162fc249b1c27f52%40djangoproject.com. For more options, visit https://groups.google.com/groups/opt_out.