Skip to content

formatEdifactDateTimePeriod

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

Write two ISO 8601 local date-times as a UN/EDIFACT DTM period (data element 2380) in a date-time period format code (data element 2379). The inverse of parseEdifactDateTimePeriod.

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

    CodeMaskThe directory’s description
    719CCYYMMDDHHMM-CCYYMMDDHHMM“A period of time which includes the century, year, month, day, hour and minute. Format of period to be given in actual message without hyphen.”
  • start and end are local date-times, as isValidDateTime accepts them: the two members parseEdifactDateTimePeriod returns. A date, an instant ending in Z and a date-time with an offset return "": the code holds no offset.

  • The period is written without a hyphen: 15 June 14:30 to 20 June 16:00 is 202406151430202406201600.

  • Precision is cut to the mask, never rounded: seconds and a fraction of a second are dropped from both ends.

  • An end before its start returns "": a reversed period names no span of time. The ends are compared as given, before either is cut to the minute. An end equal to its start is written.

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

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

ParameterTypeDescription
startstringISO 8601 local date-time the period starts at (e.g. “2024-06-15T14:30:00”)
endstringISO 8601 local date-time the period ends at (e.g. “2024-06-20T16:00:00”)
format"719"The data element 2379 format code

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

import { formatEdifactDateTimePeriod } from "@northguild/gmt/intermodal/format";
formatEdifactDateTimePeriod("2024-06-15T14:30:00", "2024-06-20T16:00:00", "719") // "202406151430202406201600"
output 

intermodal/format/formatEdifactDateTimePeriod.ts