mirror of
https://github.com/rr-/pq-cli.git
synced 2026-09-28 22:33:59 -06:00
ui: show 1d and 1h rather than 1.0d and 1.0h
This commit is contained in:
@@ -4,6 +4,13 @@ import typing as T
|
||||
import urwid
|
||||
|
||||
|
||||
def format_float(num: float) -> str:
|
||||
ret = f"{num:.01f}"
|
||||
if ret.endswith("0"):
|
||||
ret = ret[:-2]
|
||||
return ret
|
||||
|
||||
|
||||
def format_timespan(timespan: datetime.timedelta) -> str:
|
||||
num = timespan.total_seconds()
|
||||
if num < 60.0:
|
||||
@@ -13,9 +20,9 @@ def format_timespan(timespan: datetime.timedelta) -> str:
|
||||
return f"~{int(num)}m"
|
||||
num /= 60
|
||||
if num < 24.0:
|
||||
return f"~{num:.01f}h"
|
||||
return f"~{format_float(num)}h"
|
||||
num /= 24
|
||||
return f"~{num:.01f}d"
|
||||
return f"~{format_float(num)}d"
|
||||
|
||||
|
||||
class CustomProgressBar(urwid.Widget):
|
||||
|
||||
Reference in New Issue
Block a user