Function: parseAstmDate()
parseAstmDate(
raw):AstmDate|undefined
Parse an ASTM YYYYMMDDHHMMSS value, preserving whatever precision is
present. Returns undefined for a value that is not a usable timestamp (fewer
than four leading digits for the year, or non-digit content) - a caller keeps
the raw field text either way, so nothing is lost. A partial value is parsed,
never rejected.
Extra trailing digits beyond seconds (fractional seconds some vendors append) are ignored for the structured value; the full input remains in AstmDate.raw.
Parameters
raw
string
The raw field text.
Returns
AstmDate | undefined
The parsed date, or undefined when it is not a timestamp.
Example
import { parseAstmDate } from "@cosyte/astm";
parseAstmDate("20240315093000")?.precision; // "second"
parseAstmDate("202403")?.precision; // "month"