Skip to content

formatX12DateTime

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

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

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

    CodeMaskThe dictionary’s definition
    DTCCYYMMDDHHMM“Date and Time Expressed in Format CCYYMMDDHHMM”
    RTSCCYYMMDDHHMMSS“Date and Time Expressed in Format CCYYMMDDHHMMSS”
  • value is a local date-time, as isValidDateTime accepts it. A date and a time return "".

  • No 1250 code carries an offset, so an instant ending in Z and a date-time with an offset return "": an instant is not written as a wall clock. Pass the local date-time.

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

  • 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”)
formatX12DateTimeFormatX12 data element 1250 format qualifier

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

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

intermodal/format/formatX12DateTime.ts