Skip to content

isValidX12DateAndTime

  • Container free time, demurrage, billing deadlines, bill of lading dates and EDI timestamps.
isValidX12DateAndTime(date: string, time: string): boolean

Return true when the date and the time of an X12 segment, sent as two elements, together state a real local date and time.

  • ElementNameThe dictionary’s definition
    373Date“Date expressed as CCYYMMDD where CC represents the first two digits of the calendar year”
    337Time“Time expressed in 24-hour clock time as follows: HHMM, or HHMMSS, or HHMMSSD, or HHMMSSDD”
  • True exactly when parseX12DateAndTime returns a date-time for the same arguments: the validator calls the parser, so the two cannot disagree.

  • Both elements are required. A missing or empty date or time is false: check a date alone with isValidX12Date(value, "D8") and a time alone with isValidX12Time.

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

  • The date has a four-digit year and the time is 4, 6, 7 or 8 digits: a date of six digits and a time of 5 or 9 digits are false.

  • False for a non-string argument.

ParameterTypeDescription
datestringThe data element 373 date as transmitted, CCYYMMDD (e.g. “20240615”)
timestringThe data element 337 time as transmitted (e.g. “1430”)

boolean indicating validity

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

intermodal/validate/isValidX12DateAndTime.ts