Skip to main content
Version: v0.0.3

Function: parseTs()

parseTs(el, ctx): TS | undefined

Parse a TS element into a typed TS. Returns undefined when the element is absent. Emits MALFORMED_DATETIME (and omits date) when a non-empty @value does not parse. Never throws.

A @nullFlavor declared beside a populated @value is a contradiction: CONTRADICTORY_NULL_FLAVOR is emitted, raw and nullFlavor are preserved verbatim, and the derived date is withheld. That is the same treatment MALFORMED_DATETIME already gives an unparseable value, and the same rule parsePq applies to value: the parser declines to manufacture a computable reading it has been told is not the document's value, while never dropping the document's own bytes.

Parameters

el

any

ctx

ParseCtx

Returns

TS | undefined

Example

import { parseTs } from "@cosyte/ccda";
const ts = parseTs(effectiveTimeEl, { emit: () => {} });
console.log(ts?.date?.toISOString());