Skip to content

formatX12DateTimeRange

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

Write two ISO 8601 local date-times as an X12 Date Time Period range (data element 1251) in a date-time range format qualifier (data element 1250). The inverse of parseX12DateTimeRange.

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

    CodeMaskThe dictionary’s definition
    RDTCCYYMMDDHHMM-CCYYMMDDHHMM“Range of Date and Time, Expressed in Format CCYYMMDDHHMM-CCYYMMDDHHMM”
    DTSCCYYMMDDHHMMSS-CCYYMMDDHHMMSS“Range of Date and Time Expressed in Format CCYYMMDDHHMMSS-CCYYMMDDHHMMSS”
  • start and end are local date-times, as isValidDateTime accepts them: the two members parseX12DateTimeRange returns. A date, an instant ending in Z and a date-time with an offset return "": no 1250 code carries an offset.

  • The range is written with the one hyphen X12 transmits.

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

  • An end before its start returns "": a reversed range names no span of time. The ends are compared as given, before either is cut to the mask. 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 range starts at (e.g. “2024-06-15T14:30:00”)
endstringISO 8601 local date-time the range ends at (e.g. “2024-06-20T16:00:00”)
formatX12DateTimeRangeFormatX12 data element 1250 format qualifier

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

import { formatX12DateTimeRange } from "@northguild/gmt/intermodal/format";
formatX12DateTimeRange("2024-06-15T14:30:00", "2024-06-20T16:00:00", "RDT") // "202406151430-202406201600"
output 

intermodal/format/formatX12DateTimeRange.ts