> I did mess around with pytz a bit but I was getting a lot of
> exceptions - something related to the TZ already being set or
> something like that. I don't recall exactly, and I can't scroll back
> far enough to find it.
Yes, if the tzinfo attribute has already been set, you will get errors from
On Fri, Dec 23, 2016 at 2:27 PM, Skip Montanaro
wrote:
>> 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.loca
On Fri, Dec 23, 2016 at 2:18 PM, Chris Angelico wrote:
> On Sat, Dec 24, 2016 at 3:30 AM, Larry Martell
> wrote:
>> I have a datetime that looks like this: '2016-11-11T18:10:09-05:00'
>> and when I pass it to dateutil.parser.parse I get back this:
>>
>> datetime.datetime(2016, 11, 11, 18, 10, 9,
> 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 co
On Sat, Dec 24, 2016 at 3:30 AM, Larry Martell wrote:
> I have a datetime that looks like this: '2016-11-11T18:10:09-05:00'
> and when I pass it to dateutil.parser.parse I get back this:
>
> datetime.datetime(2016, 11, 11, 18, 10, 9, tzinfo=tzoffset(None, -18000))
>
> And I have other datetimes li