On May 8, 10:15 am, "Martin v. Löwis" <[EMAIL PROTECTED]> wrote: > that you are mistaken: There is NO difference between the outcome > of os.path.getmtime between Py2.5 and Py2.4. It always did return > UTC, and always will.
In revision 42230, you checked in a change to posixmodule.c with the following code comment: /* The CRT of Windows has a number of flaws wrt. its stat() implementation: - time stamps are restricted to second resolution - file modification times suffer from forth-and-back conversions between UTC and local time Therefore, we implement our own stat, based on the Win32 API directly. */ (See http://svn.python.org/view/python/trunk/Modules/posixmodule.c?rev=42230&view=log ) Different results are indeed obtained, as others have demonstrated (other than the irrelevant float/int distinction). The following C sample program illustrates: C:\>a d:\temp.txt Time modified : Thu Feb 08 10:08:44 2007 Time modified : 02/07/2007 22:08:44 UTC Time modified : 02/08/2007 11:08:44 Local C:\>c:\python24\python -c "import os;import time;print time.ctime(os.path.getmtime('temp.txt'))" Thu Feb 08 10:08:44 2007 C:\>c:\python25\python -c "import os;import time;print time.ctime(os.path.getmtime('temp.txt'))" Thu Feb 08 11:08:44 2007 (My local time is UTC-12). This doesn't happen with every file: C:\>c:\python24\python -c "import os;import time;print time.ctime(os.path.getmtime('temp2.txt'))" Tue May 08 16:59:22 2007 C:\>c:\python25\python -c "import os;import time;print time.ctime(os.path.getmtime('temp2.txt'))" Tue May 08 16:59:22 2007 C:\>a d:\temp2.txt Time modified : Tue May 08 16:59:22 2007 Time modified : 05/08/2007 04:59:22 UTC Time modified : 05/08/2007 16:59:22 Local A key fact here, I believe, is that in February (when temp.txt was last modified), my local time was UTC-11. I expect this is the suffering that your comment in posixmodule.c refers to (it looks to me like Python 2.5 is correct). Cheers, Tony --- #include <time.h> #include <sys/types.h> #include <sys/stat.h> #include <stdio.h> #include <windows.h> int main( int argc, char **argv ) { WIN32_FILE_ATTRIBUTE_DATA lpFileInformation; SYSTEMTIME stUTC, stLocal; struct __stat64 buf; int result; /* Python 2.4 style */ result = _stat64( argv[1], &buf ); if( result != 0 ) perror( "Problem getting information" ); else printf( "Time modified : %s", _ctime64( &buf.st_mtime ) ); /* Python 2.5+ */ GetFileAttributesEx(argv[1], GetFileExInfoStandard, &lpFileInformation); FileTimeToSystemTime(&lpFileInformation.ftLastWriteTime, &stUTC); printf("Time modified : %02d/%02d/%d %02d:%02d:%02d UTC\n", stUTC.wMonth, stUTC.wDay, stUTC.wYear, stUTC.wHour, stUTC.wMinute, stUTC.wSecond); SystemTimeToTzSpecificLocalTime(NULL, &stUTC, &stLocal); printf("Time modified : %02d/%02d/%d %02d:%02d:%02d Local\n", stLocal.wMonth, stLocal.wDay, stLocal.wYear, stLocal.wHour, stLocal.wMinute, stLocal.wSecond); } -- http://mail.python.org/mailman/listinfo/python-list