mmgen.util2: new format_elapsed_days_hr() function
This commit is contained in:
parent
8190e8eb0c
commit
3febba1711
1 changed files with 7 additions and 0 deletions
|
|
@ -118,6 +118,13 @@ def parse_bytespec(nbytes):
|
|||
|
||||
die(1,f'{nbytes!r}: invalid byte specifier')
|
||||
|
||||
def format_elapsed_days_hr(t,now=None,cached={}):
|
||||
e = int((now or time.time()) - t)
|
||||
if not e in cached:
|
||||
days = abs(e) // 86400
|
||||
cached[e] = f'{days} day{suf(days)} ' + ('ago' if e > 0 else 'in the future')
|
||||
return cached[e]
|
||||
|
||||
def format_elapsed_hr(t,now=None,cached={}):
|
||||
e = int((now or time.time()) - t)
|
||||
if not e in cached:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue