Skip to main content
Version: v0.0.4

Type Alias: TS

TS = DtmParts

HL7 v2 Time Stamp (TS) / Date Time (DTM) composite: the raw HL7 string plus its parsed parts, preserving the stated precision and timezone fidelity. This is a DtmParts: valid is false (with no parts) for unparseable input: NEVER throws (TYPES-04 no-throw guarantee).

There is deliberately no date field: a day-only value coerced to a JS Date at UTC midnight silently shifts the calendar day in negative-offset zones. To obtain an absolute instant, call dtmToDate(ts) explicitly (and supply assumeOffsetMinutes for an offset-less value).

Example

import type { TS } from "@cosyte/hl7";
import { dtmToDate } from "@cosyte/hl7";
const dob: TS = { raw: "19880705", valid: true, precision: "day",
year: 1988, month: 7, day: 5, hasTimezone: false };
console.log(dob.precision); // "day": not a full timestamp
console.log(dtmToDate(dob)); // undefined: refuses to guess the zone