Created
September 27, 2021 00:06
-
-
Save mogproject/b75a00ac4dff9c1451c31b077ff0bae1 to your computer and use it in GitHub Desktop.
time_convert.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import sys | |
import fileinput | |
import re | |
diff = -8 | |
def repl(matched): | |
h = int(matched.group(1)) + diff | |
prefix = '↩︎ ' if h < 0 else '↪︎ ' if h >= 24 else '' | |
return f'{prefix}{h % 24:02d}:{matched.group(2)}' | |
for line in fileinput.input(): | |
sys.stdout.write(re.sub(r'(\d+):(\d\d[^\d])', repl, line)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment