mirror of
https://github.com/markqvist/Reticulum.git
synced 2024-11-05 13:50:14 +00:00
Improved pretty print output
This commit is contained in:
parent
af3cc3c5dd
commit
38236366cf
@ -192,17 +192,21 @@ def prettyfrequency(hz, suffix="Hz"):
|
|||||||
|
|
||||||
return "%.2f%s%s" % (num, last_unit, suffix)
|
return "%.2f%s%s" % (num, last_unit, suffix)
|
||||||
|
|
||||||
def prettydistance(hz, suffix="m"):
|
def prettydistance(m, suffix="m"):
|
||||||
num = hz*1e6
|
num = m*1e6
|
||||||
units = ["µ", "m", "", "K","M","G","T","P","E","Z"]
|
units = ["µ", "m", "c", ""]
|
||||||
last_unit = "Y"
|
last_unit = "K"
|
||||||
|
|
||||||
for unit in units:
|
for unit in units:
|
||||||
if abs(num) < 1000.0:
|
divisor = 1000.0
|
||||||
return "%.2f %s%s" % (num, unit, suffix)
|
if unit == "m": divisor = 10
|
||||||
num /= 1000.0
|
if unit == "c": divisor = 100
|
||||||
|
|
||||||
return "%.2f%s%s" % (num, last_unit, suffix)
|
if abs(num) < divisor:
|
||||||
|
return "%.2f %s%s" % (num, unit, suffix)
|
||||||
|
num /= divisor
|
||||||
|
|
||||||
|
return "%.2f %s%s" % (num, last_unit, suffix)
|
||||||
|
|
||||||
def prettytime(time, verbose=False, compact=False):
|
def prettytime(time, verbose=False, compact=False):
|
||||||
days = int(time // (24 * 3600))
|
days = int(time // (24 * 3600))
|
||||||
|
Loading…
Reference in New Issue
Block a user