diff options
| author | Can Sarigol <ertugrulsarigol@gmail.com> | 2021-11-11 09:57:50 +0100 |
|---|---|---|
| committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2021-11-12 07:30:02 +0100 |
| commit | 661316b066923493ff91d6d2aa92e463f595a6b1 (patch) | |
| tree | 6730711bcf086e5692c251baadd196e0311f7236 /django/db/backends/postgresql/operations.py | |
| parent | 78163d1ac4407d59bfc5fdf1f84f2dbbb2ed3443 (diff) | |
Fixed #33279 -- Fixed handling time zones with "-" sign in names.
Thanks yakimka for the report.
Regression in fde9b7d35e4e185903cc14aa587ca870037941b1.
Diffstat (limited to 'django/db/backends/postgresql/operations.py')
| -rw-r--r-- | django/db/backends/postgresql/operations.py | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/django/db/backends/postgresql/operations.py b/django/db/backends/postgresql/operations.py index 8d19872bea..399c1b24e7 100644 --- a/django/db/backends/postgresql/operations.py +++ b/django/db/backends/postgresql/operations.py @@ -2,6 +2,7 @@ from psycopg2.extras import Inet from django.conf import settings from django.db.backends.base.operations import BaseDatabaseOperations +from django.db.backends.utils import split_tzname_delta class DatabaseOperations(BaseDatabaseOperations): @@ -44,10 +45,10 @@ class DatabaseOperations(BaseDatabaseOperations): return "DATE_TRUNC('%s', %s)" % (lookup_type, field_name) def _prepare_tzname_delta(self, tzname): - if '+' in tzname: - return tzname.replace('+', '-') - elif '-' in tzname: - return tzname.replace('-', '+') + tzname, sign, offset = split_tzname_delta(tzname) + if offset: + sign = '-' if sign == '+' else '+' + return f'{tzname}{sign}{offset}' return tzname def _convert_field_to_tz(self, field_name, tzname): |
