diff --git a/janine/utils.py b/janine/utils.py index 8ef4fb8..902b9b9 100644 --- a/janine/utils.py +++ b/janine/utils.py @@ -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): '''