Changes between Initial Version and Version 1 of Ticket #31640, comment 1
- Timestamp:
- May 29, 2020, 12:10:38 PM (5 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Ticket #31640, comment 1
initial v1 5 5 {{{#!diff 6 6 diff --git a/django/db/backends/postgresql/operations.py b/django/db/backends/postgresql/operations.py 7 index c67062a4a7.. 3877a38b431006447 index c67062a4a7..c63e4dc8c0 100644 8 8 --- a/django/db/backends/postgresql/operations.py 9 9 +++ b/django/db/backends/postgresql/operations.py … … 28 28 return field_name 29 29 30 @@ -71,7 +67,1 6@@ class DatabaseOperations(BaseDatabaseOperations):30 @@ -71,7 +67,14 @@ class DatabaseOperations(BaseDatabaseOperations): 31 31 # https://www.postgresql.org/docs/current/functions-datetime.html#FUNCTIONS-DATETIME-TRUNC 32 32 return "DATE_TRUNC('%s', %s)" % (lookup_type, field_name) … … 34 34 - def time_trunc_sql(self, lookup_type, field_name): 35 35 + def date_trunc_sql(self, lookup_type, field_name, tzname=None): 36 + if tzname: 37 + field_name = self._convert_field_to_tz(field_name, tzname) 36 + field_name = self._convert_field_to_tz(field_name, tzname) 38 37 + # https://www.postgresql.org/docs/current/functions-datetime.html#FUNCTIONS-DATETIME-TRUNC 39 38 + return "DATE_TRUNC('%s', %s)" % (lookup_type, field_name) 40 39 + 41 40 + def time_trunc_sql(self, lookup_type, field_name, tzname=None): 42 + if tzname: 43 + field_name = self._convert_field_to_tz(field_name, tzname) 41 + field_name = self._convert_field_to_tz(field_name, tzname) 44 42 + field_name = self._convert_field_to_tz(field_name, tzname) 45 43 return "DATE_TRUNC('%s', %s)::time" % (lookup_type, field_name)