From: Daniele Varrazzo Date: Fri, 14 May 2021 18:04:23 +0000 (+0200) Subject: Fix datetime timezone adjustment on Python 3.6 X-Git-Tag: 3.0.dev0~42^2~10 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=b61c79c491c11fe05b6a1aa8100755a0ab20e238;p=thirdparty%2Fpsycopg.git Fix datetime timezone adjustment on Python 3.6 --- diff --git a/psycopg3/psycopg3/types/date.py b/psycopg3/psycopg3/types/date.py index 4e4e8f8be..c959666a2 100644 --- a/psycopg3/psycopg3/types/date.py +++ b/psycopg3/psycopg3/types/date.py @@ -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):