intertwingly

It’s just data

Draconian Strftime


While making other changes to my weblogging software, I noticed that some of the code was running using Python 2.2 and others using Python 2.4 based on the entry point.  As the majority code is largely independent of the entry point, this made little sense, and without much thought I changed the primary entry point to use 2.4.

Many pages started failing.  This is due to the way in which I had constructed dates for display.  I’d take the information I knew, concatenate a bunch of zeros, and call strftime.  For example,

strftime('%a, %d %b %Y', [2006,04,07] + 6*[0])

produces Mon, 07 Apr 2006 with Python 2.2, and ValueError in Python 2.4.

The following works in both versions:

strftime('%a, %d %b %Y', [2006,04,07] + [0,0,0, 0,1,0])