Skip to content

parseEdifactTime

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

Parse a UN/EDIFACT DTM value that states a time of day, as an ISO 8601 time.

  • A DTM segment 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 codes

    CodeMaskThe 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 a 401 value and not a 402 one.

  • Seconds are always written in the result, 00 for 401.

  • 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 with parseEdifactOffsetDateTime where the partner sends 205, 208, 303 or 304.

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

ParameterTypeDescription
valuestringThe data element 2380 value (e.g. “1430”)
formatEdifactTimeFormatThe data element 2379 format code

the time as HH:MM:SS, or "" on invalid input

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

intermodal/parse/parseEdifactTime.ts