MCPcopy Create free account
hub / github.com/XingangPan/DragGAN / format_time

Function format_time

dnnlib/util.py:139–150  ·  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

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

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected