check_systemd_timer: fix time detection
This commit is contained in:
parent
7c8dbd9099
commit
5fab8adf54
|
@ -40,13 +40,13 @@ def get_next_elapse(timer_name):
|
|||
if parts.group(4):
|
||||
time_left = parse_systemctl_time_delta(parts.group(4))
|
||||
if isinstance(time_left, humanfriendly.InvalidTimespan):
|
||||
return None, humanfriendly.InvalidTimespan
|
||||
return None, Exception(f'Invalid Timespan: "{parts.group(4)}"')
|
||||
|
||||
time_passed = 'n/a'
|
||||
if parts.group(9):
|
||||
time_passed = parse_systemctl_time_delta(parts.group(9))
|
||||
if isinstance(time_passed, humanfriendly.InvalidTimespan):
|
||||
return None, humanfriendly.InvalidTimespan
|
||||
return None, Exception(f'Invalid Timespan: "{parts.group(9)}"')
|
||||
|
||||
timer_info = {
|
||||
'next': datetime_object,
|
||||
|
|
|
@ -13,7 +13,7 @@ def parse_systemctl_time_delta(time_str: str):
|
|||
spans = []
|
||||
for part in re.findall(SYSTEMCTL_TIMESPAN_RE, time_str):
|
||||
delta = part[0]
|
||||
if 'months' in delta:
|
||||
if 'month' in delta:
|
||||
# humanfriendly does not support "months" so we convert it to weeks
|
||||
num = int(delta.split(' ')[0])
|
||||
delta = f'{num * 4} weeks'
|
||||
|
|
Loading…
Reference in New Issue