nitlanguage
/
nit.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
6cf8346
)
lib/realtime: Add Timespec::to_f (and to_s) so one can print them easyly
author
Jean Privat
<jean@pryen.org>
Tue, 5 Aug 2014 02:27:15 +0000
(22:27 -0400)
committer
Jean Privat
<jean@pryen.org>
Tue, 5 Aug 2014 02:27:15 +0000
(22:27 -0400)
Signed-off-by: Jean Privat <jean@pryen.org>
lib/realtime.nit
patch
|
blob
|
history
diff --git
a/lib/realtime.nit
b/lib/realtime.nit
index
fd0fe86
..
38a601c
100644
(file)
--- a/
lib/realtime.nit
+++ b/
lib/realtime.nit
@@
-60,6
+60,12
@@
extern class Timespec `{struct timespec*`}
fun destroy `{
free( recv );
`}
+
+ # Seconds in Float
+ # Loss of precision but great to print
+ fun to_f: Float do return sec.to_f + nanosec.to_f / 1000000000.0
+
+ redef fun to_s do return "{to_f}s"
end
# Keeps track of real time