#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 | Resolution: Keywords: | Triage Stage: Unreviewed Has patch: 0 | Needs documentation: 0 Needs tests: 0 | Patch needs improvement: 0 Easy pickings: 0 | UI/UX: 0 -----------------------------+--------------------------------------
Comment (by jdufresne): I don't think this is about naive vs aware, but about accuracy. If a server's time zone is different than `settings.TIME_ZONE`, then it is important to be able to answer the question "what is today in the the timezone of `settings.TIME_ZONE`?" accurately. Near midnight different time zones will have different values for "today". This becomes useful when comparing other stored dates against "today", displaying "today", or storing "today" in the database. I have the following two convenience functions in my application to help make this job easier. For my application, they are always preferred over `datetime.date.today()`, etc. They are heavily used. {{{ def local_date(): return timezone.localtime(timezone.now()).date() def local_time(): return timezone.localtime(timezone.now()).time() }}} So I personally also see some value to this suggestion. -- Ticket URL: <https://code.djangoproject.com/ticket/27082#comment:3> 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/067.7b166fdf90b46f7c8091a6111a1ddd4d%40djangoproject.com. For more options, visit https://groups.google.com/d/optout.