diff --git a/voussoirkit/hms.py b/voussoirkit/hms.py index 47a2f7f..30bafcb 100644 --- a/voussoirkit/hms.py +++ b/voussoirkit/hms.py @@ -1,4 +1,5 @@ import math +import sys def hms_to_seconds(hms): ''' @@ -34,3 +35,18 @@ def seconds_to_hms(seconds): parts.append(seconds) hms = ':'.join(f'{part:02d}' for part in parts) return hms + +def main(args): + from voussoirkit import pipeable + for line in pipeable.go(args, strip=True, skip_blank=True): + if ':' in line: + line = hms_to_seconds(line) + else: + line = float(line) + if line > 60: + line = seconds_to_hms(line) + + pipeable.output(f'{line}') + +if __name__ == '__main__': + raise SystemExit(main(sys.argv[1:]))