Function: formatDtm()
formatDtm(
parts):string
Reconstruct the HL7 DTM string from DtmParts. The inverse of
parseDtm for a strict HL7 parse: formatDtm(parseDtm(s)) === s for
any well-formed s, including the byte-preserving -0000 (which HL7, unlike
RFC 3339, treats as UTC but whose sign we retain for exact round-trip).
Returns the raw string unchanged when parts.valid is false.
Emits exactly the populated precision, no zero-fill, so a year-only value
re-serializes to four characters, never YYYY0101.
Parameters
parts
Returns
string
Example
import { parseDtm, formatDtm } from "@cosyte/hl7";
formatDtm(parseDtm("198807050000")); // "198807050000"
formatDtm(parseDtm("1970")); // "1970"