isValidX12Time
Signature
Section titled “Signature”isValidX12Time(value: string, format?: X12TimeFormat): booleanReturn 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.
-
formatDigits Mask The dictionary’s definition omitted 4, 6, 7 or 8 HHMM,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)” TM4 HHMM“Time Expressed in Format HHMM” TS6 HHMMSS“Time Expressed in Format HHMMSS” -
True exactly when
parseX12Timereturns a time for the same arguments: the validator calls the parser, so the two cannot disagree. -
Omit
formatfor 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-02andDTP-03,DTM-05andDTM-06). -
A qualifier is strict:
"143045"is false underTM, and a 7- or 8-digit value is false under either qualifier, although all three are true with none. -
A
formatthat is present and is notTMorTSis false. -
Hour 24, minute 60, second 60 and a value of 5 or 9 digits are false.
-
False for a non-string value.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
value | string | The time as transmitted (e.g. “1430”) |
format | X12TimeFormat | X12 data element 1250 format qualifier the time arrived with; omit it for a data element 337 value |
Returns
Section titled “Returns”boolean indicating validity
Related types
Section titled “Related types”Examples
Section titled “Examples”import { isValidX12Time } from "@northguild/gmt/intermodal/validate";
isValidX12Time("1430") // true