Opened 14 months ago

Closed 14 months ago

Last modified 13 months 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.

Attachments (0)

Change History (2)

comment:1 Changed 14 months ago by aaugustin

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Resolution set to wontfix
  • Status changed from new to closed

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 13 months ago by rpq

  • Version changed from 1.4 to 1.5
Last edited 13 months ago by rpq (previous) (diff)

Add Comment

Modify Ticket

Change Properties
<Author field>
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'

E-mail address and user name can be saved in the Preferences.

Note: See TracTickets for help on using tickets.