1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-03-21 14:50:08 +03:00

bug #1130: add period_to_str method

This methods is used to create strings for time periods with this format:

  80d 10:23:33
This commit is contained in:
Javi Fontan 2012-02-13 17:52:26 +01:00
parent 6e718906bd
commit 407350bbb1

View File

@ -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")