Opened 13 years ago

Closed 13 years ago

#17343 closed Bug (fixed)

The {% now %} template tag does not use time zones

Reported by: Tomek Paczkowski Owned by: Aymeric Augustin
Component: Template system Version: dev
Severity: Release blocker Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: yes Patch needs improvement: no
Easy pickings: yes UI/UX: no

Description

Current django-trunk now tag uses datatime.now() instead of timezone.now().
I've made patch to fix that, but I'd really like to have some help with writing test.

Here's my fork over on github:
https://github.com/oinopion/django/commit/aad87fdd8cbdd02dd949da355efc4b7f127848a3

Attachments (1)

tz.diff (2.5 KB ) - added by Tomek Paczkowski 13 years ago.
Consolidated diff

Download all attachments as: .zip

Change History (5)

comment:1 by Tomek Paczkowski, 13 years ago

To clarify the issue:

Dates that are coming from Django (when using USE_TZ = True) should be presented in users current time zone.

That means this should true (regardless of time zone used):

with timezone.override('Europe/Warsaw'):
    assert Template('{% now "H:m:s" %}').render(Context()) == timezone.localtime(timezone.now()).strftime('%H:%M:%S')

Currently user is presented with date localized to default time zone.

Version 0, edited 13 years ago by Tomek Paczkowski (next)

comment:2 by Aymeric Augustin, 13 years ago

Easy pickings: set
Needs tests: set
Owner: changed from nobody to Aymeric Augustin
Severity: NormalRelease blocker
Triage Stage: UnreviewedAccepted

by Tomek Paczkowski, 13 years ago

Attachment: tz.diff added

Consolidated diff

comment:4 by Aymeric Augustin, 13 years ago

Resolution: fixed
Status: newclosed

In [17169]:

Fixed #17343 -- Changed the {% now %} tag to use the current time zone when time zone support is enabled. Thanks oinopion for the report.

Note: See TracTickets for help on using tickets.
Back to Top