I am no python guru, but according to these docs:
classmethod
datetime.today()
Return the current local datetime, with
tzinfo
None. ...
There is no time zone associated with the return value. It's not at UTC, the offset is just unspecified. It therefore makes sense that it wouldn't allow you to compare the two. The result would be meaningless.
In other words, what would you expect the result of this to be?
10 May 2013 13:00 +0200 > 10 May 2013 12:00
- It could be true, because
13:00
is a greater value than12:00
. - It could be false, because maybe the local time zone offset is
-0100
, so you are comparing the moments11:00Z > 13:00Z
. But who knows if we even meant to use the local offset since we didn't specify.
Since we are referring to an exact moment on the left side, but an ambiguous one on the right, the operation gives an error.
It's good that Python gives an error when you try to do this. Other frameworks such as .Net make some assumptions and return results that might not be what you were expecting. (Read here if you are interested.)
So going back to your question, you said:
The idea is to receive a string like this one: Wed, 8 May 2013 15:33:29 +0200 and be able to convert it in a datetime object without offset, so I can work with UTC times.
The string you have is already reflecting its offset from UTC. The way you are parsing it is just fine. You just need to compare it to something that is more meaningful, such as datetime.now(timezone.utc)