isValidEdifactDateTime
Signature
Section titled “Signature”isValidEdifactDateTime(value: string, format: EdifactDateTimeFormat): booleanReturn true when value is a UN/EDIFACT DTM value (data element 2380) that states a real date and time in a format code with no offset (data element 2379).
-
Format codes
Section titled “Format codes”Code Mask The directory’s description 203CCYYMMDDHHMM“Calendar date including time with minutes” 204CCYYMMDDHHMMSS“Calendar date including time with seconds” -
True exactly when
parseEdifactDateTimereturns 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 a203value and not a204one. -
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
isValidEdifactDtmFormat. False for a non-string argument.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
value | string | The data element 2380 value (e.g. “202406151430”) |
format | EdifactDateTimeFormat | The data element 2379 format code |
Returns
Section titled “Returns”boolean indicating validity
Related types
Section titled “Related types”Examples
Section titled “Examples”import { isValidEdifactDateTime } from "@northguild/gmt/intermodal/validate";
isValidEdifactDateTime("202406151430", "203") // true