isValidX12DateTimePeriodFormat
Signature
Section titled “Signature”isValidX12DateTimePeriodFormat(format: unknown): format is X12DateTimePeriodFormatReturn true when format is an X12 data element 1250 (Date Time Period Format Qualifier) code that the X12 functions read and write.
- The 10 supported codes are
D8,DB(a date);TM,TS(a time);DT,RTS(a date and time);RD8,RD(a range of dates) andRDT,DTS(a range of date-times).classifyX12DateTimePeriodFormatnames the kind of a code, and each kind has its own parser, formatter and validator. Release 005010, read from Stedi’s X12-licensed dictionary; the X12 text itself was not reached. The 42-code list is the same in release 008010. - A code with a two-digit year returns false:
D6,TT,TR,RD6andTU. X12 does not say which centuryYYbelongs to; read such a value withparseDateWithPatternorparseDateTimeWithPattern, ayypattern and itsyearWindowoption. TCandEH(a day of the year with no whole year),DDTandDTD(a range with a date on one side and a date-time on the other),RTM(a range of times with no date) andUN(Unstructured) return false: none states a value of one kind.- The other 21 codes of the element return false: the partial values (
CC,CY,CM,CQ,YM,MD,DD,MM,TQ,YY,MCY), the ranges of partial values (DA,RD2,RD4,RD5,RMD,RMY),RDM(YYMMDD-MMDD, a range whose end names no year) and the month-name forms (CD,KA,YMM). TS,TT,CDandMDare codes of data element 623 (Time Code) too, with unrelated meanings: hereTSisHHMMSS, andTT,CDandMDare not read; there they name the Atlantic, Central and Mountain zones. Check a time code withisValidX12TimeCode.- Matching is exact: case and spacing are not normalised.
- Accepts any input type and returns false for non-string values.
- A parser returns its sentinel for a code it does not read and for a bad value alike. Check the code here to tell a code GMT does not read apart from a value that does not fit its code.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
format | unknown | candidate value of any type |
Returns
Section titled “Returns”boolean indicating validity
X12DateTimePeriodFormat
Section titled “X12DateTimePeriodFormat”The X12 data element 1250 (Date Time Period Format Qualifier) values GMT reads and writes: 10 codes, each in the union of the one kind of value it states. Release 005010, read from Stedi’s X12-licensed dictionary; the X12 text itself was not reached. The 42-code list is the same in release 008010.
import type { X12DateTimePeriodFormat } from "@northguild/gmt";X12DateFormat | X12DateRangeFormat | X12DateTimeFormat | X12DateTimeRangeFormat | X12TimeFormatRelated types
Section titled “Related types”Examples
Section titled “Examples”import { isValidX12DateTimePeriodFormat } from "@northguild/gmt/intermodal/validate";
isValidX12DateTimePeriodFormat("D8") // true