Fix Python – Python UTC datetime object’s ISO format doesn’t include Z (Zulu or Zero offset)

Why python 2.7 doesn’t include Z character (Zulu or zero offset) at the end of UTC datetime object’s isoformat string unlike JavaScript?
>>> datetime.datetime.utcnow().isoformat()
‘2013-10-29T09:14:03.895210’

Whereas in javascript
>>> console.log(new Date().toISOString());
2013-10-29T09:38:41.341Z

….

Fix Python – How to preserve timezone when parsing date/time strings with strptime()?

I have a CSV dumpfile from a Blackberry IPD backup, created using IPDDump.
The date/time strings in here look something like this
(where EST is an Australian time-zone):
Tue Jun 22 07:46:22 EST 2010

I need to be able to parse this date in Python. At first, I tried to use the strptime() function from datettime.
>>> datetime.datetime.strptime(‘Tue ….

Fix Python – How to convert integer timestamp into a datetime

I have a data file containing timestamps like “1331856000000”. Unfortunately, I don’t have a lot of documentation for the format, so I’m not sure how the timestamp is formatted. I’ve tried Python’s standard datetime.fromordinal() and datetime.fromtimestamp() and a few others, but nothing matches. I’m pretty sure that particular number corresponds ….

Fix Python – Can’t compare naive and aware datetime.now() <= challenge.datetime_end

I am trying to compare the current date and time with dates and times specified in models using comparison operators:
if challenge.datetime_start <= datetime.now() <= challenge.datetime_end: The script errors out with: TypeError: can't compare offset-naive and offset-aware datetimes The models look like this: class Fundraising_Challenge(models.....