strftime year

Anthony Tekatch tekatch at idirect.com
Sun Jan 27 10:12:00 EST 2002


strftime seems to improperly computer the year on the December 31, 2001:

Here is an example program and it's output:


#!/usr/local/bin/python

import time,os

os.environ['TZ']='EST5EDT'

for offset in range(10):
  time_flt=1009757224.0+(offset*3*3600)
  print time_flt,
  print time.strftime('%m/%d/%g %l:%M%P',time.localtime(time_flt))


1009757224.0 12/30/01  7:07pm
1009768024.0 12/30/01 10:07pm
1009778824.0 12/31/02  1:07am
1009789624.0 12/31/02  4:07am
1009800424.0 12/31/02  7:07am
1009811224.0 12/31/02 10:07am
1009822024.0 12/31/02  1:07pm
1009832824.0 12/31/02  4:07pm
1009843624.0 12/31/02  7:07pm
1009854424.0 12/31/02 10:07pm


Note, December 31 should still be year "01".

Am I doing something wrong?



More information about the Python-list mailing list