spoqa / sqlalchemy-utc

SQLAlchemy type to store aware datetime values
https://pypi.python.org/pypi/SQLAlchemy-Utc
MIT License
101 stars 20 forks source link

Consider returning UTC datetimes #6

Closed bolkedebruin closed 3 years ago

bolkedebruin commented 6 years ago

I have been bitten by the assumption that UTCDateTime always has a representation of the DateTime in UTC. It actually hasn't. While everything is sent to the database as UTC it isnt returned as UTC when the database does a transformation. This can lead to unexpected results, ie getting a datetime back with a different timezone offset than it was originally stored in.

In my case I was storing UTC datetimes, but the DB was configured 'Europe/Amsterdam' and thus was returning datetimes in 'Europe/Amsterdam'.

ThiefMaster commented 5 years ago

I REALLY do not want to (have to) care about the timezone configured in my database, so this is currently forcing me to use a custom UTCDateTime implementation instead of just installing this package.

So always getting UTC (unless you opt-in to keeping the timezone returned by the database) would be much nicer IMHO.