[pywin32-bugs] [ pywin32-Bugs-3420417 ] PyTime value returned from FindFilesIterator is incorrect
OLD project page for the Python extensions for Windows
Brought to you by:
mhammond
From: SourceForge.net <no...@so...> - 2011-10-07 20:09:59
|
Bugs item #3420417, was opened at 2011-10-07 15:21 Message generated for change (Comment added) made by calconst You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=551954&aid=3420417&group_id=78018 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: win32 Group: None Status: Open Resolution: None Priority: 6 Private: No Submitted By: Caleb Constantine (calconst) Assigned to: Nobody/Anonymous (nobody) Summary: PyTime value returned from FindFilesIterator is incorrect Initial Comment: 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. ---------------------------------------------------------------------- >Comment By: Caleb Constantine (calconst) Date: 2011-10-07 16:09 Message: 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. ---------------------------------------------------------------------- Comment By: Caleb Constantine (calconst) Date: 2011-10-07 15:29 Message: This bug might be related to bug ID 2831327, "GetProcessTimes converts wrongly to PyTime". ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=551954&aid=3420417&group_id=78018 |