#568 PyTime value returned from FindFilesIterator is incorrect

closed-wont-fix
nobody
win32 (141)
6
2012-01-08
2011-10-07
No

The PyTime value in the WIN32_FIND_DATA object returned from FindFilesIterator() is incorrect. Say fdata is an instance returned from FindFilesIterator(), then time.localtime(int(fdata[3])) returns the UTC time, not the local time.

To reproduce:
(1) Create a new text file, say C:\test.txt
(2) Observe the modification date.
(3) Run the script on the command line with the path to the file created in (1) as the argument, e.g. pytimebug.py C:\test.txt
(4) Observe local time printed on screen is incorrect; in fact it is the UTC time.

Discussion

  • Caleb Constantine

    Script to reprodce the bug

     
  • Caleb Constantine

    • priority: 5 --> 6
     
  • Caleb Constantine

    This bug might be related to bug ID 2831327, "GetProcessTimes converts wrongly to PyTime".

     
  • Caleb Constantine

    It seems the PyTime value (returned from FindFilesIterator()) is offset from the correct value by the value of the UTC offset. E.g, if I find the UTC offset, and subtract this from the PyTime before converting to localtime, I get the correct result:

    utc_offset = (datetime.utcnow() - datetime.now()).total_seconds()
    ftime = time.localtime(int(finfo[3]) - utc_offset)

    Now ftime is correct.

     
  • Mark Hammond

    Mark Hammond - 2012-01-08

    Yeah - like 2831327, I'm reluctant to fix this as it may break people already working around it and it doesn't exist in py3k.

     
  • Mark Hammond

    Mark Hammond - 2012-01-08
    • status: open --> closed-wont-fix
     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks