Re: [Django] #23524: Django postgres connection's timezone is always set to UTC. Breaks date_trunc function

2014-09-28 Thread Django
#23524: Django postgres connection's timezone is always set to UTC. Breaks
date_trunc function
--+--
 Reporter:  Mactory   |Owner:
 Type:  Bug   |   Status:  closed
Component:  contrib.postgres  |  Version:  1.6
 Severity:  Normal|   Resolution:  invalid
 Keywords:| Triage Stage:  Unreviewed
Has patch:  0 |  Needs documentation:  0
  Needs tests:  0 |  Patch needs improvement:  0
Easy pickings:  0 |UI/UX:  0
--+--
Changes (by aaugustin):

 * status:  new => closed
 * needs_better_patch:   => 0
 * resolution:   => invalid
 * needs_tests:   => 0
 * needs_docs:   => 0


Comment:

 This is by design and it's
 [https://docs.djangoproject.com/en/stable/ref/databases/#optimizing-
 postgresql-s-configuration documented]. See also the discussions on
 django-developers leading to the implementation of time zone support in
 Django 1.4.

 You may use `connection.ops.datetime_trunc_sql` (a private API), or look
 at what it returns and reimplement it by yourself.

--
Ticket URL: <https://code.djangoproject.com/ticket/23524#comment:1>
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/065.683b6c8c74e560e13fd4b51115066b98%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


[Django] #23524: Django postgres connection's timezone is always set to UTC. Breaks date_trunc function

2014-09-19 Thread Django
#23524: Django postgres connection's timezone is always set to UTC. Breaks
date_trunc function
--+-
 Reporter:  Mactory   |  Owner:
 Type:  Bug   | Status:  new
Component:  contrib.postgres  |Version:  1.6
 Severity:  Normal|   Keywords:
 Triage Stage:  Unreviewed|  Has patch:  0
Easy pickings:  0 |  UI/UX:  0
--+-
 When using a cursor created by  django.db.connection.cursor() to execute a
 database function on a postgresql database, the timezone of the database
 connection is always set to UTC instead of using the specified TIME_ZONE.
 This behavior brakes postgres' {{{ date_trunc }}} function, since it will
 truncate the hour to be 0 at UTC creating an offset from midnight at the
 local timestamp.

 Example:
 settings.py
 {{{
 TIME_ZONE = 'Europe/Berlin' # Offset +2
 USE_TZ = TRUE
 }}}

 using date_trunc in a djago python shell:
 {{{
 ./manage.py shell
 >>> from django.db import connection
 >>> cursor = connection.cursor()
 >>> cursor.execute("select date_trunc('month', TIMESTAMP WITH TIME ZONE
 '2014-09-14 04:10:00+02');")
 >>> unicode(cursor.fetchone()[0])
 u'2014-09-01 00:00:00+00:00'
 }}}

 using date_tunc directly in psql:
 {{{
 psql db
 db=#select date_trunc('month', TIMESTAMP WITH TIME ZONE '2014-09-14
 04:10:00+02');
date_trunc
 
  2014-09-01 00:00:00+02
 (1 row)
 }}}

 For executing custom functions for which no return value is needed, the
 following workaround does work:
 {{{
 >>> cursor.execute("SET TIMEZONE to %s;select date_trunc('month',
 TIMESTAMP WITH TIME ZONE '2014-09-14 04:10:00+02');SET TIMEZONE to
 'UTC';", (settings.TIME_ZONE,))
 }}}

--
Ticket URL: <https://code.djangoproject.com/ticket/23524>
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/050.a782c3138b99e9a7bf17ec3ff34a5dfc%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.