Add main function to hms.py.
This commit is contained in:
parent
3a5e160504
commit
16b1d85dbd
1 changed files with 16 additions and 0 deletions
|
@ -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:]))
|
||||
|
|
Loading…
Reference in a new issue