def _tmdd_datetime_to_iso(dt, include_offset=True, include_seconds=True):
datestring = dt.findtext('<STR_LIT:date>')<EOL>timestring = dt.findtext('<STR_LIT:time>')<EOL>assert len(datestring) == <NUM_LIT:8><EOL>assert len(timestring) >= <NUM_LIT:6><EOL>iso = datestring[<NUM_LIT:0>:<NUM_LIT:4>] + '<STR_LIT:->' + datestring[<NUM_LIT:4>:<NUM_LIT:6>] + '<STR_LIT:->' + datestring[<NUM_LIT:6>:<NUM_LIT:8>] + '<STR_LIT:T>'+ timestring[<NUM_LIT:0>:<NUM_LIT:2>] + '<STR_LIT::>' + timestring[<NUM_LIT:2>:<NUM_LIT:4>]<EOL>if include_seconds:<EOL><INDENT>iso += '<STR_LIT::>' + timestring[<NUM_LIT:4>:<NUM_LIT:6>]<EOL><DEDENT>if include_offset:<EOL><INDENT>offset = dt.findtext('<STR_LIT>')<EOL>if offset:<EOL><INDENT>assert len(offset) == <NUM_LIT:5><EOL>iso += offset[<NUM_LIT:0>:<NUM_LIT:3>] + '<STR_LIT::>' + offset[<NUM_LIT:3>:<NUM_LIT:5>]<EOL><DEDENT>else:<EOL><INDENT>raise Exception("<STR_LIT>" % etree.tostring(dt))<EOL><DEDENT><DEDENT>return iso<EOL>
dt is an xml Element with <date>, <time>, and optionally <offset> children.
returns an ISO8601 string