Skip to content

isValidX12Time

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

Return true when value is an X12 time that states a real time of day: a data element 337 value with no qualifier, or a time that fits the data element 1250 format qualifier it arrived with.

  • formatDigitsMaskThe dictionary’s definition
    omitted4, 6, 7 or 8HHMM, HHMMSS, HHMMSSD, HHMMSSDDElement 337: “H = hours (00-23), M = minutes (00-59), S = integer seconds (00-59) … D = tenths (0-9) and DD = hundredths (00-99)”
    TM4HHMM“Time Expressed in Format HHMM”
    TS6HHMMSS“Time Expressed in Format HHMMSS”
  • True exactly when parseX12Time returns a time for the same arguments: the validator calls the parser, so the two cannot disagree.

  • Omit format for the time element of a freight segment (AT7-06, G62-04, DTM-03), which has no qualifier. Pass it for a time that arrives with one (DTP-02 and DTP-03, DTM-05 and DTM-06).

  • A qualifier is strict: "143045" is false under TM, and a 7- or 8-digit value is false under either qualifier, although all three are true with none.

  • A format that is present and is not TM or TS is false.

  • Hour 24, minute 60, second 60 and a value of 5 or 9 digits are false.

  • False for a non-string value.

ParameterTypeDescription
valuestringThe time as transmitted (e.g. “1430”)
formatX12TimeFormatX12 data element 1250 format qualifier the time arrived with; omit it for a data element 337 value

boolean indicating validity

import { isValidX12Time } from "@northguild/gmt/intermodal/validate";
isValidX12Time("1430") // true
output 

intermodal/validate/isValidX12Time.ts