Isoformat in Python 2.4

Sometimes I don't like python. Just sometimes, I love it most of the times. But just look what hoops I need to jump through to get a current timestamp in ISO format:

from datetime import datetime, tzinfo, timedelta

import time

class TZ(tzinfo): def utcoffset(self,dt): return timedelta(seconds=time.timezone) def dst(self,dt): return timedelta(0)

a = datetime.now(TZ())

a= a.replace(microsecond = 0)

print a.isoformat()

That prints:

asterisk:~ tim$ python test.py

2008-03-24T13:38:06-01:00

Fugly...

Comments

Comments powered by Disqus