Skip to content

formatEdifactDateTime

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

Write an ISO 8601 local date-time as a UN/EDIFACT DTM value (data element 2380) in a format code with no offset (data element 2379). The inverse of parseEdifactDateTime.

  • Masks and descriptions are the UNTDID directory’s, read from UNECE’s D.21B page as archived. ### Format codes

    CodeMaskThe directory’s description
    203CCYYMMDDHHMM“Calendar date including time with minutes”
    204CCYYMMDDHHMMSS“Calendar date including time with seconds”
  • value is a local date-time, as isValidDateTime accepts it. A date, a time, an instant ending in Z and a date-time with an offset return "": these codes hold no offset. Write an instant with formatEdifactOffsetDateTime.

  • Precision is cut to the mask, never rounded: a fraction of a second is always dropped, and 203 drops the seconds too. 2024-06-15T14:30:45.9 is 202406151430 under 203 and 20240615143045 under 204.

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

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

ParameterTypeDescription
valuestringISO 8601 local date-time (e.g. “2024-06-15T14:30:00”)
formatEdifactDateTimeFormatThe data element 2379 format code

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

import { formatEdifactDateTime } from "@northguild/gmt/intermodal/format";
formatEdifactDateTime("2024-06-15T14:30:00", "203") // "202406151430"
output 

intermodal/format/formatEdifactDateTime.ts