[python-win32] Why I get wrong filetime values with win32 api(FindFilesW) ?
Christian Stooker
durumdara at mailpont.hu
Thu May 11 09:47:54 CEST 2006
Mark Hammond írta:
> I'm guessing it is related to the GMT offset. The MSDN docs for the
> FILETIME structure say:
>
> Furthermore, FAT records times on disk in local time. However,
> NTFS records times on disk in UTC. For more information ...
>
> Otherwise I'm afraid I have no idea...
>
> Mark
>
>
Hi !
As I say: interesting, because os.get*time functions get good result for
the files.
####################################################
import os,sys,win32file,win32api,time
uFiles=win32file.FindFilesW(os.path.join(os.getcwd(),'*'))
for uFile in uFiles:
fullfn=os.path.join(os.getcwd(),uFile[8])
#fullfn=win32api.GetShortPathName(fullfn)
#print [fullfn]
if os.path.isfile(fullfn):
print [fullfn]
w32modtime=uFile[3]
osmodtime=os.path.getmtime(fullfn)
print "pw32",int(w32modtime)
print "pyos",osmodtime
print "pw32",time.asctime((time.localtime(int(w32modtime))))
print "pyos",time.asctime((time.localtime(osmodtime)))
####################################################
Commandline: C:\Python24\python.exe g:\TESTFI~1.PY
Workingdirectory: g:\
Timeout: 0 ms
[u'g:\\AH.odt']
pw32 1137145550
pyos 1137152750
pw32 Fri Jan 13 10:45:50 2006
pyos Fri Jan 13 12:45:50 2006
[u'g:\\Depeche Lyrics.odt']
pw32 1143800308
pyos 1143807508
pw32 Fri Mar 31 12:18:28 2006
pyos Fri Mar 31 14:18:28 2006
[u'g:\\KFJ.xcf']
pw32 1145886140
pyos 1145893340
pw32 Mon Apr 24 15:42:20 2006
pyos Mon Apr 24 17:42:20 2006
[u'g:\\KFJ.jpg']
pw32 1145886156
pyos 1145893356
pw32 Mon Apr 24 15:42:36 2006
pyos Mon Apr 24 17:42:36 2006
[u'g:\\KFJ2.xcf']
pw32 1145886504
pyos 1145893704
pw32 Mon Apr 24 15:48:24 2006
pyos Mon Apr 24 17:48:24 2006
[u'g:\\KFJ2.jpg']
pw32 1145886530
pyos 1145893730
pw32 Mon Apr 24 15:48:50 2006
pyos Mon Apr 24 17:48:50 2006
[u'g:\\Megasztar.odt']
pw32 1146226088
pyos 1146233288
pw32 Fri Apr 28 14:08:08 2006
pyos Fri Apr 28 16:08:08 2006
[u'g:\\fastpython.html']
pw32 1147008590
pyos 1147015790
pw32 Sun May 07 15:29:50 2006
pyos Sun May 07 17:29:50 2006
[u'g:\\PerformanceTips.htm']
pw32 1147008540
pyos 1147015740
pw32 Sun May 07 15:29:00 2006
pyos Sun May 07 17:29:00 2006
[u'g:\\[wxPython-users] How to force GenericDirCtrl to show hidden and
system files and dirs.html']
pw32 1147089932
pyos 1147097132
pw32 Mon May 08 14:05:32 2006
pyos Mon May 08 16:05:32 2006
[u'g:\\000372.html']
pw32 1143205264
pyos 1143212464
pw32 Fri Mar 24 14:01:04 2006
pyos Fri Mar 24 16:01:04 2006
[u'g:\\example1.html']
pw32 1143635508
pyos 1143642708
pw32 Wed Mar 29 14:31:48 2006
pyos Wed Mar 29 16:31:48 2006
[u'g:\\gml-tr.html']
pw32 1143462646
pyos 1143469846
pw32 Mon Mar 27 14:30:46 2006
pyos Mon Mar 27 16:30:46 2006
[u'g:\\index.php.htm']
pw32 1143205404
pyos 1143212604
pw32 Fri Mar 24 14:03:24 2006
pyos Fri Mar 24 16:03:24 2006
[u'g:\\tlprenderManual.html']
pw32 1143635836
pyos 1143643036
pw32 Wed Mar 29 14:37:16 2006
pyos Wed Mar 29 16:37:16 2006
[u'g:\\usage.html']
pw32 1145880100
pyos 1145887300
pw32 Mon Apr 24 14:01:40 2006
pyos Mon Apr 24 16:01:40 2006
[u'g:\\testfiletimes.py']
pw32 1147326262
pyos 1147333462
pw32 Thu May 11 07:44:22 2006
pyos Thu May 11 09:44:22 2006
Process "Pyhton Interpeter" terminated, ExitCode: 00000000
####################################################
As you can see, the different is two hours.
We are in GMT+01 timezone, and I use NTFS and WXP.
I hope this help to find a bug, or get the solution.
dd
More information about the Python-win32
mailing list