[IMP] runbot: use babel helper to format timedelta

It allow minimal granularity to minutes and rollover thresholds.
This commit is contained in:
Christophe Simonis 2019-06-27 17:41:03 +02:00 committed by Christophe Simonis
parent 857821e41a
commit 059957282e

View File

@ -11,6 +11,9 @@ import socket
import time
from collections import OrderedDict
from datetime import timedelta
from babel.dates import format_timedelta
from odoo.tools.misc import DEFAULT_SERVER_DATETIME_FORMAT
@ -83,11 +86,11 @@ def rfind(filename, pattern):
def s2human(time):
"""Convert a time in second into an human readable string"""
for delay, desc in [(86400, 'd'),(3600, 'h'),(60, 'm')]:
if time >= delay:
return str(int(time / delay)) + desc
return str(int(time)) + "s"
return format_timedelta(
timedelta(seconds=time),
format="narrow",
threshold=2.1,
)
@contextlib.contextmanager
def local_pgadmin_cursor():