Convert the seconds to human readable string with days, hours, minutes and seconds.
(seconds: Union[int, float])
| 140 | |
| 141 | |
| 142 | def 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 | |
| 156 | def ask_yes_no(question: str) -> bool: |
nothing calls this directly
no outgoing calls
no test coverage detected