#27082: Make timezone.localtime() default to timezone.now() when no value is given ---------------------------------------+------------------------ Reporter: bmispelon | Owner: nobody Type: New feature | Status: new Component: Utilities | Version: 1.10 Severity: Normal | Keywords: Triage Stage: Unreviewed | Has patch: 0 Needs documentation: 0 | Needs tests: 0 Patch needs improvement: 0 | Easy pickings: 0 UI/UX: 0 | ---------------------------------------+------------------------ Sometimes I find that I need to get the current date in the context of the active time zone.
As far as I understand, the correct way to do this is `timezone.localtime(timezone.now()).date()`. It'd be nice if we `localtime` would default to using `timezone.now()` is no value is given, so that I could simply do `timezone.localtime().date()`. This should be straightforward to implement, except for the case where `settings.USE_TZ = False` because `timezone.now()` would then return a naive datetime and `localtime()` would throw an error. -- Ticket URL: <https://code.djangoproject.com/ticket/27082> 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/052.cd1d4795bb7f05e908eee999e3cad74f%40djangoproject.com. For more options, visit https://groups.google.com/d/optout.