#include <time.h>
`}
-redef class Object
- # Unix time: the number of seconds elapsed since January 1, 1970
- protected fun get_time: Int `{ return time(NULL); `}
-end
+# Unix time: the number of seconds elapsed since January 1, 1970
+fun get_time: Int `{ return time(NULL); `}
redef class Sys
# Wait a specific number of second and nanoseconds
`}
end
+redef class Float
+ # Sleep approximately `self` seconds
+ fun sleep `{
+ time_t s = self;
+ long ns = (self-s) * 1000000000.0;
+ const struct timespec req = {s, ns};
+ nanosleep(&req, NULL);
+ `}
+end
+
# Time since epoch
extern class TimeT `{time_t`}