[IronPython] os.stat doesn't return time values in seconds
Sanghyeon Seo
sanxiyn at gmail.com
Tue May 2 11:55:25 CEST 2006
# test.py
import os, time
name = "newfile"
f = open(name, "w")
f.close()
t = time.time()
mt = os.stat(name).st_mtime
print t, mt
Expected result: t and mt doesn't differ by more than 1.
Attached patch fixes the problem.
Seo Sanghyeon
-------------- next part --------------
--- IronPython/Modules/nt.cs.orig 2006-04-18 14:23:18.000000000 +0900
+++ IronPython/Modules/nt.cs 2006-05-02 18:51:08.000000000 +0900
@@ -297,7 +297,8 @@
[PythonType("stat_result")]
public class StatResult {
- internal long mode, ino, dev, nlink, uid, gid, size, atime, mtime, ctime;
+ internal long mode, ino, dev, nlink, uid, gid, size;
+ internal double atime, mtime, ctime;
public StatResult() {
}
@@ -316,13 +317,13 @@
this.ctime = ctime;
}
- public long StatATime {
+ public double StatATime {
[PythonName("st_atime")]
get {
return atime;
}
}
- public long StatCTime {
+ public double StatCTime {
[PythonName("st_ctime")]
get {
return ctime;
@@ -352,7 +353,7 @@
return mode;
}
}
- public long StatMTime {
+ public double StatMTime {
[PythonName("st_mtime")]
get {
return mtime;
@@ -401,9 +402,9 @@
StatResult sr = new StatResult();
try {
- sr.atime = Directory.GetLastAccessTime(path).Ticks;
- sr.ctime = Directory.GetCreationTime(path).Ticks;
- sr.mtime = Directory.GetLastWriteTime(path).Ticks;
+ sr.atime = Directory.GetLastAccessTime(path).Ticks / 1.0e7;
+ sr.ctime = Directory.GetCreationTime(path).Ticks / 1.0e7;
+ sr.mtime = Directory.GetLastWriteTime(path).Ticks / 1.0e7;
if (Directory.Exists(path)) {
sr.mode = 0x4000;
More information about the Ironpython-users
mailing list