isValidX12TimeCode
Signature
Section titled “Signature”isValidX12TimeCode(timeCode: unknown): timeCode is X12TimeCodeReturn true when timeCode is one of the 56 X12 data element 623 time codes, the codes x12TimeCodeOffset and x12TimeCodeZone read between them.
- The codes are
01–29,GM,UT,LTand the named zone codes (AD,AS,AT,CD,CS,CT,ED,ES,ET,HD,HS,HT,MD,MS,MT,ND,NS,NT,PD,PS,PT,TD,TS,TT), release 008010, read from Stedi’s X12-licensed dictionary; the X12 text itself was not reached. - The function takes no release, so it accepts the superset. Release 005010 has 51 of the codes:
25–29were added in release 006010 and are not valid in an 004010 or 005010 interchange, although this returns true for them. TS,TT,CDandMDare codes of data element 1250 too, with unrelated meanings there. True here says the value is a time code; check a format qualifier withisValidX12DateTimePeriodFormat.- Membership is by the list, never by shape:
00and30are two digits and are not codes. - Matching is exact: two characters, upper case, no padding.
- Accepts any input type and returns false for non-string values.
- True exactly when one of
x12TimeCodeOffsetandx12TimeCodeZonereturns a value: the 31 codes that state an offset and the 25 that name a zone are the 56. A valid code says the value is in the list, not that it carries an offset:ESis valid and names a zone.classifyX12TimeCodesays which of the two a code is, and narrows it for that reader.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
timeCode | unknown | candidate value of any type |
Returns
Section titled “Returns”boolean indicating validity
X12TimeCode
Section titled “X12TimeCode”The 56 X12 data element 623 (Time Code) values, release 008010, read from Stedi’s X12-licensed dictionary; the X12 text itself was not reached.
import type { X12TimeCode } from "@northguild/gmt";"TS" | "01" | "02" | "03" | "04" | "05" | "06" | "07" | "08" | "09" | "10" | "11" | "12" | "13" | "14" | "15" | "16" | "17" | "18" | "19" | "20" | "21" | "22" | "23" | "24" | "25" | "26" | "27" | "28" | "29" | "GM" | "UT" | "AD" | "AS" | "AT" | "CD" | "CS" | "CT" | "ED" | "ES" | "ET" | "HD" | "HS" | "HT" | "LT" | "MD" | "MS" | "MT" | "ND" | "NS" | "NT" | "PD" | "PS" | "PT" | "TD" | "TT"Examples
Section titled “Examples”import { isValidX12TimeCode } from "@northguild/gmt/intermodal/validate";
isValidX12TimeCode("ES") // true