dateutil timezone question

Skip Montanaro skip.montanaro at
Fri Dec 23 14:27:49 EST 2016

> I need to compare these datetimes, and if I do that I get the dreaded
> "can't compare offset-naive and offset-aware datetimes" error.

If you're sure the naive datetimes are UTC, this should work:

import pytz

dt = pytz.utc.localize(dateutil.parser.parse('2016-04-27T00:00:00'))

You can then compare it with other tz-containing datetime objects.


More information about the Python-list mailing list