All but the GMT offset is easy. If you already have it use it.
Assuming I have an HL7 with a full date/time like:
set dt 20051130133330.0000-0600
set dateTime [string range $dt 0 13]
set gmt [string range $dt end-4 end]
# Make scanable
regsub — {^(d{8})(d*$)} $dateTime {1 2} dateTime
set xmlTime [clock format [clock scan $dateTime]
-format “%Y-%m-%dT%H%M%S$gmt”]
=> 2005-11-30T133330-0600
If not given GMT offset and assuming you always use offset relative to your local time you can set it to a constant