feat: Pad time

This commit is contained in:
PapaTutuWawa 2021-03-07 15:32:07 +01:00
parent 4eb89534fe
commit bfd02fb1be

View File

@ -30,6 +30,15 @@ def make_msg(to, body):
return msg
def pad_time_component(c):
'''
If we have 12:08, it gets turned into 12:8, so we need to pad
the components with a leading zero, if there is none.
'''
if len(c) != 2:
return f'0{c}'
return c
def format_time(time_str):
'''
Reformat ISO style time data to a more
@ -40,7 +49,7 @@ def format_time(time_str):
except ValueError:
return time_str
return f'{date.day}.{date.month}.{date.year} {date.hour}:{date.minute}'
return f'{date.day}.{date.month}.{date.year} {pad_time_component(date.hour)}:{pad_time_component(date.minute)}'
def format_warning(warning):
'''