Skip to content

formatX12DateRange

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

Write two ISO 8601 dates as an X12 Date Time Period range (data element 1251) in a date range format qualifier (data element 1250). The inverse of parseX12DateRange.

  • Codes are release 005010, read from Stedi’s X12-licensed dictionary; the X12 text itself was not reached. ### Format codes

    CodeMaskThe dictionary’s definition
    RD8CCYYMMDD-CCYYMMDD“Range of Dates Expressed in Format CCYYMMDD-CCYYMMDD”
    RDMMDDCCYY-MMDDCCYY“Range of Dates Expressed in Format MMDDCCYY-MMDDCCYY”
  • start and end are dates, as isValidDate accepts them: the two members parseX12DateRange returns. A date-time, an instant or a time returns "".

  • The range is written with the one hyphen X12 transmits: 15 to 20 June 2024 is 20240615-20240620 under RD8.

  • An end before its start returns "": a reversed range 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 range starts on (e.g. “2024-06-15”)
endstringISO 8601 date the range ends on (e.g. “2024-06-20”)
formatX12DateRangeFormatX12 data element 1250 format qualifier

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

import { formatX12DateRange } from "@northguild/gmt/intermodal/format";
formatX12DateRange("2024-06-15", "2024-06-20", "RD8") // "20240615-20240620"
output 

intermodal/format/formatX12DateRange.ts