formatEdifactTime
Signature
Section titled “Signature”formatEdifactTime(value: string, format: EdifactTimeFormat): stringWrite an ISO 8601 time as a UN/EDIFACT DTM value (data element 2380) in a time format code (data element 2379). The inverse of parseEdifactTime.
-
Masks and descriptions are the UNTDID directory’s, read from UNECE’s D.21B page as archived. ### Format codes
Code Mask The directory’s description 401HHMM“Time without seconds: H = Hour; m = Minute.” 402HHMMSS“Time with seconds: H = Hour; m = Minute; s = Seconds.” -
valueis a time, asisValidTimeaccepts it:HH:MM, with seconds and a fraction of a second if it has them. A date-time, a date or a time with an offset returns"". -
Precision is cut to the mask, never rounded: a fraction of a second is always dropped, and
401drops the seconds too.14:30:59.9is1430under401and143059under402, andparseEdifactTimereads back the time the mask holds. -
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 | ISO 8601 time (e.g. “14:30:00”) |
format | EdifactTimeFormat | The data element 2379 format code |
Returns
Section titled “Returns”the data element 2380 value, or "" on invalid input
Related types
Section titled “Related types”Examples
Section titled “Examples”import { formatEdifactTime } from "@northguild/gmt/intermodal/format";
formatEdifactTime("14:30:00", "401") // "1430"