Skip to content

formatEdifactTime

  • Container free time, demurrage, billing deadlines, bill of lading dates and EDI timestamps.
formatEdifactTime(value: string, format: EdifactTimeFormat): string

Write 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

    CodeMaskThe directory’s description
    401HHMM“Time without seconds: H = Hour; m = Minute.”
    402HHMMSS“Time with seconds: H = Hour; m = Minute; s = Seconds.”
  • value is a time, as isValidTime accepts 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 401 drops the seconds too. 14:30:59.9 is 1430 under 401 and 143059 under 402, and parseEdifactTime reads back the time the mask holds.

  • Returns "" for any other code, a code of another kind included, and for a non-string argument.

ParameterTypeDescription
valuestringISO 8601 time (e.g. “14:30:00”)
formatEdifactTimeFormatThe data element 2379 format code

the data element 2380 value, or "" on invalid input

import { formatEdifactTime } from "@northguild/gmt/intermodal/format";
formatEdifactTime("14:30:00", "401") // "1430"
output 

intermodal/format/formatEdifactTime.ts