isValidX12DateAndTime
Signature
Section titled “Signature”isValidX12DateAndTime(date: string, time: string): booleanReturn true when the date and the time of an X12 segment, sent as two elements, together state a real local date and time.
-
The two elements
Section titled “The two elements” -
True exactly when
parseX12DateAndTimereturns 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 withisValidX12Time. -
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.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
date | string | The data element 373 date as transmitted, CCYYMMDD (e.g. “20240615”) |
time | string | The data element 337 time as transmitted (e.g. “1430”) |
Returns
Section titled “Returns”boolean indicating validity
Examples
Section titled “Examples”import { isValidX12DateAndTime } from "@northguild/gmt/intermodal/validate";
isValidX12DateAndTime("20240615", "1430") // true