MCPcopy Create free account
hub / github.com/Vchitect/Latte / format_time

Function format_time

tools/dnnlib/util.py:142–153  ·  view source on GitHub ↗

Convert the seconds to human readable string with days, hours, minutes and seconds.

(seconds: Union[int, float])

Source from the content-addressed store, hash-verified

140
141
142def format_time(seconds: Union[int, float]) -> str:
143 """Convert the seconds to human readable string with days, hours, minutes and seconds."""
144 s = int(np.rint(seconds))
145
146 if s < 60:
147 return "{0}s".format(s)
148 elif s < 60 * 60:
149 return "{0}m {1:02}s".format(s // 60, s % 60)
150 elif s < 24 * 60 * 60:
151 return "{0}h {1:02}m {2:02}s".format(s // (60 * 60), (s // 60) % 60, s % 60)
152 else:
153 return "{0}d {1:02}h {2:02}m".format(s // (24 * 60 * 60), (s // (60 * 60)) % 24, (s // 60) % 60)
154
155
156def ask_yes_no(question: str) -> bool:

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected