stoiclion's picture
Agent Workbench tasks and environment at e59670df
b5d1dbc verified
Raw History Blame Contribute Delete
268 Bytes
def parse_duration(text):
"""Parse durations like '1h30m', '45s', '2h5s' or '90m' into total seconds."""
import re
total = 0
for value, unit in re.findall(r"(\d+)([hm])", text):
total += int(value) * {"h": 3600, "m": 60}[unit]
return total