isValidEdifactDtmFormat
Signature
Section titled “Signature”isValidEdifactDtmFormat(format: unknown): format is EdifactDtmFormatReturn true when format is a UN/EDIFACT data element 2379 format code that the EDIFACT functions read and write.
- The 11 supported codes are
102(a date);401,402(a time);203,204(a date and time with no offset);205,208,303,304(a date and time with an offset);718(a period of dates) and719(a period of date-times).classifyEdifactDtmFormatnames the kind of a code, and each kind has its own parser, formatter and validator. - A code with a two-digit year returns false:
101,201,202,206,207,301,302,713and717. UN/EDIFACT does not say which centuryYYbelongs to; read such a value withparseDateWithPatternorparseDateTimeWithPattern, ayypattern and itsyearWindowoption. 209and404(a time with an offset and no date) and406(an offset alone) return false: none names a date, a time, a date-time or an instant.- Every other 2379 code returns false: the day-first and month-first dates
2–5,10(CCYYMMDDTHHMM),103, the ordinal date105,210,307,308, the time spans501–503,711, the partial values, the weekday period720and the quantities (801and up). - Matching is exact:
" 203","0203"and the number203are not codes. - Accepts any input type and returns false for non-string values.
- A parser returns its sentinel for a code it does not read, the same sentinel it returns for a value that does not fit its code. Check the code here to tell an unsupported format apart from bad data.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
format | unknown | candidate value of any type |
Returns
Section titled “Returns”boolean indicating validity
EdifactDtmFormat
Section titled “EdifactDtmFormat”The UN/EDIFACT data element 2379 (Date or time or period format code) values GMT reads and writes: 11 codes, each in the union of the one kind of value it states. Twelve directories were read: UNECE’s own D.21B and D.22B pages, archived, and mirrors of D.93A, D.96A, D.01B, D.01C, D.03A, D.03B, D.04B, D.11B, D.12A and D.13B. No mask of a code GMT reads changed across them.
import type { EdifactDtmFormat } from "@northguild/gmt";"102" | "718" | EdifactDateTimeFormat | "719" | EdifactOffsetDateTimeFormat | EdifactTimeFormatRelated types
Section titled “Related types”EdifactDateFormatEdifactTimeFormatEdifactDateTimeFormatEdifactOffsetDateTimeFormatEdifactDatePeriodFormatEdifactDateTimePeriodFormat
Examples
Section titled “Examples”import { isValidEdifactDtmFormat } from "@northguild/gmt/intermodal/validate";
isValidEdifactDtmFormat("203") // true