parseEdifactTime
Signature
Section titled “Signature”parseEdifactTime(value: string, format: EdifactTimeFormat): stringParse a UN/EDIFACT DTM value that states a time of day, as an ISO 8601 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 time with no date and no offset. Masks and descriptions are the UNTDID directory’s, read from UNECE’s D.21B page as archived. ### Format codesCode Mask The directory’s description 401HHMM“Time without seconds: H = Hour; m = Minute.” 402HHMMSS“Time with seconds: H = Hour; m = Minute; s = Seconds.” -
The value must be the digits of its code’s mask:
"1430"is a401value and not a402one. -
Seconds are always written in the result,
00for401. -
Fields are checked, not clamped: hour 24, minute 60 and second 60 return
"". -
A time with an offset (
209,404) is not read: with no date it names no instant. Read the date and time together withparseEdifactOffsetDateTimewhere the partner sends205,208,303or304. -
Returns
""for any other code, a code of another kind included, and for a non-string argument.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
value | string | The data element 2380 value (e.g. “1430”) |
format | EdifactTimeFormat | The data element 2379 format code |
Returns
Section titled “Returns”the time as HH:MM:SS, or "" on invalid input
Related types
Section titled “Related types”Examples
Section titled “Examples”import { parseEdifactTime } from "@northguild/gmt/intermodal/parse";
parseEdifactTime("1430", "401") // "14:30:00"