def to_iso8601(value, strict=True, force_int=True):
<EOL>seconds = to_seconds(value, strict, force_int)<EOL>minutes, seconds = divmod(seconds, <NUM_LIT>)<EOL>hours, minutes = divmod(minutes, <NUM_LIT>)<EOL>days, hours = divmod(hours, <NUM_LIT>)<EOL>days, hours, minutes = map(int, (days, hours, minutes))<EOL>seconds = round(seconds, <NUM_LIT:6>)<EOL>date = '<STR_LIT>'<EOL>if days:<EOL><INDENT>date = '<STR_LIT>' % days<EOL><DEDENT>time = '<STR_LIT:T>'<EOL>bigger_exists = date or hours<EOL>if bigger_exists:<EOL><INDENT>time += '<STR_LIT>'.format(hours)<EOL><DEDENT>bigger_exists = bigger_exists or minutes<EOL>if bigger_exists:<EOL><INDENT>time += '<STR_LIT>'.format(minutes)<EOL><DEDENT>if isinstance(seconds, int) or force_int:<EOL><INDENT>seconds = '<STR_LIT>'.format(int(seconds))<EOL><DEDENT>else:<EOL><INDENT>seconds = '<STR_LIT>' % seconds<EOL><DEDENT>time += '<STR_LIT>'.format(seconds)<EOL>return '<STR_LIT:P>' + date + time<EOL>
converts duration value to ISO8601 string
accepts integers, hh:mm:ss or mm:ss strings, timedelta objects

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