MagicStack / asyncpg

A fast PostgreSQL Database Client Library for Python/asyncio.
Apache License 2.0
6.88k stars 399 forks source link

Use UTC for `timestamp without time zone` #1176

Open WillPCowan opened 4 weeks ago

WillPCowan commented 4 weeks ago

asyncpg converts timestamps to datetime.datetime. If a column has type timestamp without time zone then the datetime object's .tzinfo is None. This means datetime implicitly treats this datetime as if it is local, and source code has to replace tzinfo for every column that has timestamp without time zone.

I'd expect that when developers specify no timezone it is intended to be UTC, otherwise timezone would be specified in the postgres datatype?

With this in mind it makes sense to provide UTC timezone type when creating datetime.datetime objects from columns that do not specify timezone (at least IMO).