Skip to main content
Version: v0.0.4

Interface: DtmParts

Parsed HL7 v2 TS/DTM value: the raw string plus its structural parts, with the stated precision and timezone fidelity preserved. This is the shape of the TS composite (field.asTs()) and every helper datetime.

The parts are only populated when valid is true. month/day/… are spec-native (month is 1–12, NOT the JS Date 0–11). offsetMinutes is present iff hasTimezone is true and is signed minutes east of UTC (+0500300, -0430-270). A missing offset is flagged (hasTimezone: false), never resolved to UTC: the consumer decides how to localize with dtmToDate.

Example

import type { DtmParts } from "@cosyte/hl7";
const dob: DtmParts = {
raw: "19880705", valid: true, precision: "day",
year: 1988, month: 7, day: 5, hasTimezone: false,
};

Properties

day?

readonly optional day?: number

Day of month, 1–31.


fractionalSeconds?

readonly optional fractionalSeconds?: string

Fractional-second digits exactly as populated (no leading dot), e.g. "5" (0.5 s), "0500" (0.05 s). Preserved verbatim: never rounded.


hasTimezone

readonly hasTimezone: boolean

true iff an explicit +/-ZZZZ offset was present.


hour?

readonly optional hour?: number

Hour, 0–23.


matchedFormat?

readonly optional matchedFormat?: string

The fallback format that matched (parseDtmCascade only), e.g. "MM/DD/YYYY" or "ISO-8601". Absent for a strict HL7 DTM parse.


minute?

readonly optional minute?: number

Minute, 0–59.


month?

readonly optional month?: number

Month, 1–12 (spec-native, NOT JS 0–11).


offsetMinutes?

readonly optional offsetMinutes?: number

Signed minutes east of UTC; present iff hasTimezone is true.


precision?

readonly optional precision?: DtmPrecision

Stated precision; absent when valid is false.


raw

readonly raw: string

The original HL7 string, exactly as it appeared (already unescaped).


second?

readonly optional second?: number

Second, 0–59.


valid

readonly valid: boolean

true when raw is a well-formed, in-range HL7 DTM (or a matched fallback format). false for empty, malformed, or calendar-out-of-range input: in which case only raw and hasTimezone: false are meaningful.


year?

readonly optional year?: number

Four-digit year.