Opened 5 years ago

Closed 5 years ago

Last modified 5 years ago

#19835 closed Bug (wontfix) should return local time when used with timezone.activate

Reported by: bach@… Owned by: nobody
Component: Core (Other) Version: 1.5
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


I think using should return a timezone aware datetime object when used in conjunction with timezone.activate

For example,

now =

now is a value that is UTC time instead of US/Pacific time. I understand that activate is used for rendering in templates but it's confusing when a user calls activate expecting that timezone to be activated and doesn't obey that activation. If they aren't supposed to work together, I don't think they should belong in the same module.

Change History (2)

comment:1 Changed 5 years ago by Aymeric Augustin

Resolution: wontfix
Status: newclosed

timezone.activate() isn't used only for templates. It's used to change the current time zone. This affects QuerySet.datetimes for example. uses neither the default not the current time zone. It works as documented and it would be quite disruptive to change its behavior.

Thanks for the proposal, but I'm not sure it's a good idea (using UTC here was a deliberate choice) and the drawbacks of a change certainly outweigh the advantages at this point.

Use timezone.localtime() to convert an aware datetime to another timezone.

comment:2 Changed 5 years ago by rpq

Version: 1.41.5
Last edited 5 years ago by rpq (previous) (diff)
Note: See TracTickets for help on using tickets.
Back to Top