def to_timedelta(value, strict=True):
if isinstance(value, int):<EOL><INDENT>return timedelta(seconds=value)  <EOL><DEDENT>elif isinstance(value, timedelta):<EOL><INDENT>return value<EOL><DEDENT>elif isinstance(value, str):<EOL><INDENT>hours, minutes, seconds = _parse(value, strict)<EOL><DEDENT>elif isinstance(value, tuple):<EOL><INDENT>check_tuple(value, strict)<EOL>hours, minutes, seconds = value<EOL><DEDENT>else:<EOL><INDENT>raise TypeError(<EOL>'<STR_LIT>' % (<EOL>value, type(value).__name__<EOL>)<EOL>)<EOL><DEDENT>return timedelta(hours=hours, minutes=minutes, seconds=seconds)<EOL>
converts duration string to timedelta

strict=True (by default) raises StrictnessError if either hours,
minutes or seconds in duration string exceed allowed values