strftime year

John Roth johnroth at ameritech.net
Sun Jan 27 11:12:56 EST 2002


"Anthony Tekatch" <tekatch at idirect.com> wrote in message
news:AFU48.1035$9y2.118114 at news20.bellglobal.com...
> 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?

Amusing, what? It looks like someone has a residual
Y2K bug there. Since Python generally uses the existing
C compiler and library in a given environment, that would
be the place to start looking for the bug.

You might also try looking at the bug reports at the
Python project on sourceforge. I doubt seriously
that if it's a Python problem, it would have gone
unreported this long.

John Roth





More information about the Python-list mailing list