[Tutor] Formatting questions regarding datetime.isoformat()

staticsafe me at staticsafe.ca
Thu Sep 6 05:00:15 CEST 2012


I am running Python 2.6.6 on a Debian Squeeze system. I am using two
modules in this bit of code - datetime and python-tvrage (available on
pypy here: http://pypi.python.org/pypi/python-tvrage/).

My goal is to find the time remaining until a certain show airs. Here is
some code I have written so far:

#!/usr/bin/env python
from tvrage import quickinfo
from datetime import tzinfo, timedelta, datetime

showinfo = quickinfo.fetch("Warehouse 13")
nextairdate = showinfo['RFC3369']
now = datetime.now().isoformat()

Now for my question/problem.

In [68]: showinfo['RFC3339']
Out[68]: '2012-09-10T21:00:00-4:00'

In [72]: datetime.now().isoformat()
Out[72]: '2012-09-05T22:47:46.061688'

isoformat() is in a different format than the value returned by the API.
My question is how would one format both values so that I can perform a
timedelta on them as is the purpose of my code?

I hope I have provided the right amount of detail for my question.


More information about the Tutor mailing list