pw_presubmit: Better formatting for long times

Change-Id: I3f5ed338718ede5a93900217bd7b4fbe31159c26
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/33120
Pigweed-Auto-Submit: Rob Mohr <mohrr@google.com>
Commit-Queue: Auto-Submit <auto-submit@pigweed.google.com.iam.gserviceaccount.com>
Reviewed-by: Keir Mierle <keir@google.com>
This commit is contained in:
Rob Mohr 2021-02-18 07:49:40 -08:00 committed by CQ Bot Account
parent 969f44ef3f
commit a303b4f879

View File

@ -83,7 +83,10 @@ def _title(msg, style=_SUMMARY_BOX) -> str:
def _format_time(time_s: float) -> str:
minutes, seconds = divmod(time_s, 60)
return f' {int(minutes)}:{seconds:04.1f}'
if minutes < 60:
return f' {int(minutes)}:{seconds:04.1f}'
hours, minutes = divmod(minutes, 60)
return f'{int(hours):d}:{int(minutes):02}:{int(seconds):02}'
def _box(style, left, middle, right, box=tools.make_box('><>')) -> str: