Matt Nordhoff wrote:
Tim H wrote:
On Win XP 64bit, Python 2.6.1 64bit

I am trying to rename files by their creation time.

It seems the time module is too smart for its own good here.

time.localtime(os.path.getctime(f)) returns a value one hour off
from what windows reports for files that were created when Daylight
savings time was in effect (ie when the tm_isdst field is one).  I
can kludge it, but am I missing the "right" way to do it?

Tim

full code:

<snip full code>

From what I remember, this is a bug in the Win32 API. Python
probably could hack around it, but, well, I guess it doesn't.

Googling a bit, Perl's Win32::UTCFileTime module [1] provides workarounds (not for Python, of course, but it could probably be
ported) and explains all the gory details (which I have not read, so
maybe I misunderstand ;-).

[1] <http://search.cpan.org/~shay/Win32-UTCFileTime-1.50/lib/Win32/UTCFileTime.pm>
 <http://xrl.us/beezsv>

Windows does apply the current value of DST when converting from UTC to local time.

The problem is that the rules for when DST starts and ends might change over time and from place to place, and local time depends on the
timezone too.

Probably the best you can do is just to apply the current rules and accept that the result might not match what the local time actually was.
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to