Skip to content

formatEdifactDate

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

Write an ISO 8601 date as a UN/EDIFACT DTM value (data element 2380) in a date format code (data element 2379). The inverse of parseEdifactDate: what one writes, the other reads back.

  • The mask and description are the UNTDID directory’s, read from UNECE’s D.21B page as archived. ### Format code

    CodeMaskThe directory’s description
    102CCYYMMDD“Calendar date: C = Century ; Y = Year ; M = Month ; D = Day.”
  • value is a date, as isValidDate accepts it. A date-time, an instant or a time returns "", as formatDate returns "" for them: pass the date alone.

  • Each field is zero-padded to the width the mask gives it.

  • A year outside 0000–9999 returns "": CCYY is four digits and no sign.

  • No function writes a two-digit year (101, YYMMDD): the one date code that is written holds the whole year.

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

ParameterTypeDescription
valuestringISO 8601 date (e.g. “2024-06-15”)
format"102"The data element 2379 format code

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

import { formatEdifactDate } from "@northguild/gmt/intermodal/format";
formatEdifactDate("2024-06-15", "102") // "20240615"
output 

intermodal/format/formatEdifactDate.ts