]> git.ipfire.org Git - thirdparty/psycopg.git/commitdiff
Fix datetime timezone adjustment on Python 3.6
authorDaniele Varrazzo <daniele.varrazzo@gmail.com>
Fri, 14 May 2021 18:04:23 +0000 (20:04 +0200)
committerDaniele Varrazzo <daniele.varrazzo@gmail.com>
Fri, 14 May 2021 18:04:39 +0000 (20:04 +0200)
psycopg3/psycopg3/types/date.py

index 4e4e8f8bee5ef8271c8d0ed72e5751a1cbcc45b6..c959666a2c6bc8341d13c949195d15c8f5afe2fd 100644 (file)
@@ -586,7 +586,11 @@ class TimestampTzLoader(TimestampLoader):
             tzoff = -tzoff
 
         rv = super().load(data[: m.start()])
-        return (rv - tzoff).replace(tzinfo=self._timezone)
+        return (
+            (rv - tzoff)
+            .replace(tzinfo=timezone.utc)
+            .astimezone(self._timezone)
+        )
 
     def _load_notimpl(self, data: Buffer) -> datetime:
         if isinstance(data, memoryview):