mirror of
https://github.com/odoo/runbot.git
synced 2025-03-16 07:55:45 +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
|
||||
|
||||
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():
|
||||
|
Loading…
Reference in New Issue
Block a user