parseX12DateTime
Signature
Section titled “Signature”parseX12DateTime(value: string, format: X12DateTimeFormat): stringParse an X12 Date Time Period value that states a date and a time, as an ISO 8601 local date-time.
-
A
DTPsegment carries a format qualifier inDTP-02(data element 1250) and its value inDTP-03(data element 1251);DTM-05andDTM-06carry the same pair. This function reads the codes whose value is one date-time. Codes are release 005010, read from Stedi’s X12-licensed dictionary; the X12 text itself was not reached. ### Format codesCode Mask The dictionary’s definition DTCCYYMMDDHHMM“Date and Time Expressed in Format CCYYMMDDHHMM” RTSCCYYMMDDHHMMSS“Date and Time Expressed in Format CCYYMMDDHHMMSS” -
The result is local, never UTC. No 1250 code carries an offset, so the result has no
Zand no offset. Pass it and the place’s IANA zone toresolveLocalto get the instant. -
RTSis one date-time, despite theRthat marks a range in other codes. -
The value must be the digits of its code’s mask:
"202406151430"is aDTvalue and not anRTSone. -
Seconds are always written in the result,
00forDT. -
Fields are checked, not clamped: hour 24, second 60, 31 June and 29 February 2023 return
"". -
A freight segment sends the date and the time as two elements (373 and 337 in
AT7,G62andDTM-02/03), not as one 1250 value: read those withparseX12DateAndTime. -
A two-digit year (
TR,DDMMYYHHMM) is not read: X12 does not say which century it belongs to. Read one withparseDateTimeWithPattern("1506241430", "ddMMyyHHmm", undefined, { yearWindow: 2000 }). -
Returns
""for any other code, a code of another kind included (D8is read byparseX12Date), and for a non-string argument.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
value | string | The data element 1251 value (e.g. “202406151430”) |
format | X12DateTimeFormat | X12 data element 1250 format qualifier |
Returns
Section titled “Returns”the local date-time as YYYY-MM-DDTHH:MM:SS, or "" on invalid input
Related types
Section titled “Related types”Examples
Section titled “Examples”import { parseX12DateTime } from "@northguild/gmt/intermodal/parse";
parseX12DateTime("202406151430", "DT") // "2024-06-15T14:30:00"