Skip to content

formatEdifactDatePeriod

  • Container free time, demurrage, billing deadlines, bill of lading dates and EDI timestamps.
formatEdifactDatePeriod(start: string, end: string, format: "718"): string

Write two ISO 8601 dates as a UN/EDIFACT DTM period (data element 2380) in a date period format code (data element 2379). The inverse of parseEdifactDatePeriod.

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

    CodeMaskThe directory’s description
    718CCYYMMDD-CCYYMMDD“A period of time specified by giving the start date followed by the end date (both including century). Data is to be transmitted as consecutive characters without hyphen.”
  • start and end are dates, as isValidDate accepts them: the two members parseEdifactDatePeriod returns. A date-time or an instant returns "".

  • The period is written without a hyphen, as every directory read says it is transmitted: 15 to 20 June 2024 is 2024061520240620.

  • An end before its start returns "": a reversed period names no span of time. An end equal to its start is written.

  • A year outside 0000–9999 in either date returns "".

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

ParameterTypeDescription
startstringISO 8601 date the period starts on (e.g. “2024-06-15”)
endstringISO 8601 date the period ends on (e.g. “2024-06-20”)
format"718"The data element 2379 format code

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

import { formatEdifactDatePeriod } from "@northguild/gmt/intermodal/format";
formatEdifactDatePeriod("2024-06-15", "2024-06-20", "718") // "2024061520240620"
output 

intermodal/format/formatEdifactDatePeriod.ts