MCPcopy Create free account
hub / github.com/PierreGode/Ragnar / format_interval

Method format_interval

pager_lib/tqdm/std.py:400–417  ·  view source on GitHub ↗

Formats a number of seconds as a clock time, [H:]MM:SS Parameters ---------- t : int Number of seconds. Returns ------- out : str [H:]MM:SS

(t)

Source from the content-addressed store, hash-verified

398
399 @staticmethod
400 def format_interval(t):
401 """
402 Formats a number of seconds as a clock time, [H:]MM:SS
403
404 Parameters
405 ----------
406 t : int
407 Number of seconds.
408
409 Returns
410 -------
411 out : str
412 [H:]MM:SS
413 """
414 sign = '-' if t < 0 else ''
415 mins, s = divmod(abs(int(t)), 60)
416 h, m = divmod(mins, 60)
417 return f'{sign}{h:d}:{m:02d}:{s:02d}' if h else f'{sign}{m:02d}:{s:02d}'
418
419 @staticmethod
420 def format_num(n):

Callers 1

format_meterMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected