Commit 2f79c5f6 authored by Thomas Lotze's avatar Thomas Lotze

fix parsing of times in tracking notes

parent d2bfba4b
......@@ -3,8 +3,13 @@ from gitlab import Gitlab
def parse_action(action):
op, time_str = action.split()
op, time_str = action.split(None, 1)
sign = dict(added=1, subtracted=-1)[op]
value = sum(parse_time(piece) for piece in time_str.split())
return sign * value
def parse_time(time_str):
ulen = 2 if time_str.endswith('mo') else 1
value_str, unit_str = time_str[:-ulen], time_str[-ulen:]
unit = dict(
......@@ -15,7 +20,7 @@ def parse_action(action):
m=60,
s=1,
)[unit_str]
return sign * float(value_str) * unit
return float(value_str) * unit
def fetch(url, token):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment