From 407350bbb198826ffcb0dc1bf9cb1a822a415761 Mon Sep 17 00:00:00 2001 From: Javi Fontan Date: Mon, 13 Feb 2012 17:52:26 +0100 Subject: [PATCH] bug #1130: add period_to_str method This methods is used to create strings for time periods with this format: 80d 10:23:33 --- src/cli/one_helper.rb | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/cli/one_helper.rb b/src/cli/one_helper.rb index e900a963bc..dc81700cb6 100644 --- a/src/cli/one_helper.rb +++ b/src/cli/one_helper.rb @@ -364,6 +364,15 @@ EOT end end + def OpenNebulaHelper.period_to_str(time) + seconds=time.to_i + minutes, seconds=seconds.divmod(60) + hours, minutes=minutes.divmod(60) + days, hours=hours.divmod(24) + + "%4dd %02d:%02d:%02d" % [days, hours, minutes, seconds] + end + BinarySufix = ["K", "M", "G", "T" ] def OpenNebulaHelper.unit_to_str(value, options, unit="K")