From ae807dd119b501be5f2911bbdd7fa7e0c7616f38 Mon Sep 17 00:00:00 2001 From: Jean Privat Date: Mon, 4 Aug 2014 22:27:15 -0400 Subject: [PATCH 1/1] lib/realtime: Add Timespec::to_f (and to_s) so one can print them easyly Signed-off-by: Jean Privat --- lib/realtime.nit | 6 ++++++ 1 file changed, 6 insertions(+) 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 -- 1.7.9.5