From: Jean Privat Date: Tue, 5 Aug 2014 02:27:15 +0000 (-0400) Subject: lib/realtime: Add Timespec::to_f (and to_s) so one can print them easyly X-Git-Tag: v0.6.8~31^2~4 X-Git-Url: http://nitlanguage.org?hp=6cf8346242693bd40a37ce124baa5c48443cd869 lib/realtime: Add Timespec::to_f (and to_s) so one can print them easyly Signed-off-by: Jean Privat --- diff --git a/lib/realtime.nit b/lib/realtime.nit index fd0fe86..38a601c 100644 --- 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