#29884: QuerySet.filter() with TruncBase functions not working as expected when USE_TZ= True -------------------------------------+------------------------------------- Reporter: slide333333 | Owner: (none) Type: Bug | Status: new Component: Database layer | Version: 2.1 (models, ORM) | Severity: Normal | Resolution: Keywords: | Triage Stage: Accepted Has patch: 0 | Needs documentation: 0 Needs tests: 0 | Patch needs improvement: 0 Easy pickings: 0 | UI/UX: 0 -------------------------------------+-------------------------------------
Comment (by Simon Charette): > One thing I notice is that make_aware is surprisingly not the same thing as adding the tzinfo to the datetime in the first place. Except for the `TIME_ZONE` setting omission that [https://groups.google.com/d/msg/django- developers/cyqlZnN3HUQ/CRhOOft1AwAJ Aymeric mentioned on the mailing list] there's a big difference between `datetime(2018, 10, 24, tzinfo=tz)` and `tz.localize(datetime(2018, 10, 24))` which is what `make_aware` does. The first will assign the timezone `Europe/Berlin` timezone [https://en.wikipedia.org/wiki/Time_in_Germany#History as it was first defined] and the latter will assign the timezone as it is defined on the specified datetime. In other words direct `tzinfo`, assignment will create highly likely bogus datetime objects (unless a timezone definition such as UTC is used) while `localize` will make sure the right timezone is used. In your case `datetime(2018, 10, 24, tzinfo=euberlin)` creates a datetime for 2018-10-24 with the timezone definition of `Europe/Berlin` in 1901. -- Ticket URL: <https://code.djangoproject.com/ticket/29884#comment:11> 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/069.cfe136578eee274c71ca9207de658a4e%40djangoproject.com. For more options, visit https://groups.google.com/d/optout.