diff options
| author | Shafiya Adzhani <adz.arsym@gmail.com> | 2024-02-03 20:05:15 +0700 |
|---|---|---|
| committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2024-02-15 10:02:57 +0100 |
| commit | 22285d366c9061a668003638613685f5a135a4c3 (patch) | |
| tree | 6affd1a303f71cce709403f69760f83936810963 /django/db/backends/sqlite3/_functions.py | |
| parent | 2aa8388110f5639c0dc410b22cb741c679f0749e (diff) | |
Fixed #33037 -- Fixed Trunc() with offset timezones on MySQL, SQLite, Oracle.
Diffstat (limited to 'django/db/backends/sqlite3/_functions.py')
| -rw-r--r-- | django/db/backends/sqlite3/_functions.py | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/django/db/backends/sqlite3/_functions.py b/django/db/backends/sqlite3/_functions.py index 0171b60f38..6d07d3d78b 100644 --- a/django/db/backends/sqlite3/_functions.py +++ b/django/db/backends/sqlite3/_functions.py @@ -118,7 +118,10 @@ def _sqlite_datetime_parse(dt, tzname=None, conn_tzname=None): hours, minutes = offset.split(":") offset_delta = timedelta(hours=int(hours), minutes=int(minutes)) dt += offset_delta if sign == "+" else -offset_delta - dt = timezone.localtime(dt, zoneinfo.ZoneInfo(tzname)) + # The tzname may originally be just the offset e.g. "+3:00", + # which becomes an empty string after splitting the sign and offset. + # In this case, use the conn_tzname as fallback. + dt = timezone.localtime(dt, zoneinfo.ZoneInfo(tzname or conn_tzname)) return dt |
