[pywin32-bugs] [ pywin32-Bugs-3454662 ] GetFileAttributesEx, GetFileTime yield wrong time
OLD project page for the Python extensions for Windows
Brought to you by:
mhammond
From: SourceForge.net <no...@so...> - 2011-12-08 21:06:31
|
Bugs item #3454662, was opened at 2011-12-08 13:06 Message generated for change (Tracker Item Submitted) made by kxroberto You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=551954&aid=3454662&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: None Group: None Status: Open Resolution: None Priority: 5 Private: No Submitted By: kxroberto (kxroberto) Assigned to: Nobody/Anonymous (nobody) Summary: GetFileAttributesEx, GetFileTime yield wrong time Initial Comment: > >>> os.path.getmtime('x.txt') > 1193160881 > >>> int(win32file.GetFileAttributesExW('x.txt')[-2]) > 1193153681 > >>> int(win32file.GetFileAttributesExW('x.txt')[-2]) - > os.path.getmtime('x.txt') > -7200 > > (Win XP) > is this a bug, or is there a issue with timezones/summer time? > aren't time.time() values absolute? > had this issue again. py_GetFileAttributesEx creates <PyTime> objects from (linear) FILETIME). PyTime stores linear time as well (Windows VariantTime "DATE"), but the conversion is done via SYSTEMTIME - with hour,minute,... :-) py_GetFileAttributesEx > PyObject_FromFILEX_INFO > PyWinObject_FromFILETIME > FileTimeToSystemTime > PyTime Upon int(<PyTime>) the conversion from PyTime back to linear time is again done via SYSTEMTIME. These conversions via SYSTEMTIME are somehow buggy and principally bogus (during daylight-saving transition hours) overall. => the bug should perhaps be fixed by computing Pytime.m_time directly from FILETIME via y = a*x + b perhaps even better: GetFileAttributesEx should simply return Pythonic time.time() style linear time stamps, not PyTime. (but not backwards compatible; possibly by a flag parameter) Python example for linear time conversion: def FILETIME2time(ft): "returns time.time() style seconds from FILETIME" tutc = ft.dwHighDateTime * 4294967296L + ft.dwLowDateTime tt = tutc * 100e-9 - 11644473600 return tt ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=551954&aid=3454662&group_id=78018 |