Skip to content

isValidX12DateTime

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

Return true when value is an X12 Date Time Period value (data element 1251) that states a real date and time in a date-time format qualifier (data element 1250).

  • CodeMaskThe dictionary’s definition
    DTCCYYMMDDHHMM“Date and Time Expressed in Format CCYYMMDDHHMM”
    RTSCCYYMMDDHHMMSS“Date and Time Expressed in Format CCYYMMDDHHMMSS”
  • True exactly when parseX12DateTime returns a date-time for the same arguments: the validator calls the parser, so the two cannot disagree.

  • A value is valid only against its code: "202406151430" is a DT value and not an RTS one.

  • Checks the calendar as well as the shape: 31 June, 29 February 2023, hour 24 and second 60 are false.

  • False for any other code, a code of another kind included; check a code alone with isValidX12DateTimePeriodFormat. False for a non-string argument.

ParameterTypeDescription
valuestringThe data element 1251 value (e.g. “202406151430”)
formatX12DateTimeFormatX12 data element 1250 format qualifier

boolean indicating validity

import { isValidX12DateTime } from "@northguild/gmt/intermodal/validate";
isValidX12DateTime("202406151430", "DT") // true
output 

intermodal/validate/isValidX12DateTime.ts