parseEdifactDateTime
Signature
Section titled “Signature”parseEdifactDateTime(value: string, format: EdifactDateTimeFormat): stringParse a UN/EDIFACT DTM value that states a date and a time with no offset, as an ISO 8601 local date-time.
-
A
DTMsegment carries its value in data element 2380 and, in data element 2379, the format code that says how to read it. This function reads the codes whose value is a wall clock at a place the value does not name. Masks and descriptions are the UNTDID directory’s, read from UNECE’s D.21B page as archived. ### Format codesCode Mask The directory’s description 203CCYYMMDDHHMM“Calendar date including time with minutes” 204CCYYMMDDHHMMSS“Calendar date including time with seconds” -
The result is local, never UTC. It carries no
Zand no offset: reading a203value as UTC is the most common EDI timestamp bug. Pass the result and the place’s IANA zone toresolveLocalto get the instant. -
The value must be the digits of its code’s mask:
"202406151430"is a203value and not a204one. -
Seconds are always written in the result,
00for203. -
Fields are checked, not clamped: hour 24, second 60, 31 June and 29 February 2023 return
"". -
A two-digit year (
201,202) is not read: UN/EDIFACT does not say which century it belongs to. Read one withparseDateTimeWithPattern("2406151430", "yyMMddHHmm", undefined, { yearWindow: 2000 }). -
Returns
""for any other code, a code of another kind included (205is read byparseEdifactOffsetDateTime), and for a non-string argument.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
value | string | The data element 2380 value (e.g. “202406151430”) |
format | EdifactDateTimeFormat | The data element 2379 format code |
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 { parseEdifactDateTime } from "@northguild/gmt/intermodal/parse";
parseEdifactDateTime("202406151430", "203") // "2024-06-15T14:30:00"