From bfb06d46c91825228848d9579f082e7057edb0bd Mon Sep 17 00:00:00 2001 From: Ethan Dalool Date: Sun, 16 May 2021 20:31:35 -0700 Subject: [PATCH] Add parameters force_hours, force_minutes. --- voussoirkit/hms.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/voussoirkit/hms.py b/voussoirkit/hms.py index 8389fcf..a25bf91 100644 --- a/voussoirkit/hms.py +++ b/voussoirkit/hms.py @@ -19,7 +19,7 @@ def hms_to_seconds(hms): seconds += float(parts[0]) return seconds -def seconds_to_hms(seconds): +def seconds_to_hms(seconds, force_minutes=False, force_hours=False): ''' Convert integer number of seconds to an hh:mm:ss string. Only the necessary fields are used. @@ -28,9 +28,9 @@ def seconds_to_hms(seconds): (minutes, seconds) = divmod(seconds, 60) (hours, minutes) = divmod(minutes, 60) parts = [] - if hours: + if hours or force_hours: parts.append(hours) - if hours or minutes: + if hours or minutes or force_hours or force_minutes: parts.append(minutes) parts.append(seconds) hms = ':'.join(f'{part:02d}' for part in parts)