mirror of
https://github.com/odoo/runbot.git
synced 2025-03-27 13:25:47 +07:00
[IMP] runbot: use babel helper to format timedelta
It allow minimal granularity to minutes and rollover thresholds.
This commit is contained in:
parent
857821e41a
commit
059957282e
@ -11,6 +11,9 @@ import socket
|
|||||||
import time
|
import time
|
||||||
|
|
||||||
from collections import OrderedDict
|
from collections import OrderedDict
|
||||||
|
from datetime import timedelta
|
||||||
|
|
||||||
|
from babel.dates import format_timedelta
|
||||||
|
|
||||||
from odoo.tools.misc import DEFAULT_SERVER_DATETIME_FORMAT
|
from odoo.tools.misc import DEFAULT_SERVER_DATETIME_FORMAT
|
||||||
|
|
||||||
@ -83,11 +86,11 @@ def rfind(filename, pattern):
|
|||||||
|
|
||||||
def s2human(time):
|
def s2human(time):
|
||||||
"""Convert a time in second into an human readable string"""
|
"""Convert a time in second into an human readable string"""
|
||||||
for delay, desc in [(86400, 'd'),(3600, 'h'),(60, 'm')]:
|
return format_timedelta(
|
||||||
if time >= delay:
|
timedelta(seconds=time),
|
||||||
return str(int(time / delay)) + desc
|
format="narrow",
|
||||||
return str(int(time)) + "s"
|
threshold=2.1,
|
||||||
|
)
|
||||||
|
|
||||||
@contextlib.contextmanager
|
@contextlib.contextmanager
|
||||||
def local_pgadmin_cursor():
|
def local_pgadmin_cursor():
|
||||||
|
Loading…
Reference in New Issue
Block a user