# isValidX12TimeCode

Industry: Intermodal

## Signature

```ts
isValidX12TimeCode(timeCode: unknown): timeCode is X12TimeCode
```

Return 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`, `LT` and 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](https://www.stedi.com/edi/x12-008010/element/623); the X12 text itself was not reached.
- **The function takes no release, so it accepts the superset.** [Release 005010](https://www.stedi.com/edi/x12-005010/element/623) has 51 of the codes: `25`–`29` were added in release 006010 and are not valid in an 004010 or 005010 interchange, although this returns true for them.
- `TS`, `TT`, `CD` and `MD` are codes of data element 1250 too, with unrelated meanings there. True here says the value is a time code; check a format qualifier with `isValidX12DateTimePeriodFormat`.
- Membership is by the list, never by shape: `00` and `30` are 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 `x12TimeCodeOffset` and `x12TimeCodeZone` returns 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: `ES` is valid and names a zone. `classifyX12TimeCode` says which of the two a code is, and narrows it for that reader.

## Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| `timeCode` | `unknown` | candidate value of any type |

## Returns

boolean indicating validity

## Types

### X12TimeCode

The 56 X12 data element 623 (Time Code) values, release 008010, read from [Stedi's X12-licensed dictionary](https://www.stedi.com/edi/x12-008010/element/623); the X12 text itself was not reached.

```ts
import type { X12TimeCode } from "@northguild/gmt";
```

```ts
"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

```ts
import { isValidX12TimeCode } from "@northguild/gmt/intermodal/validate";

isValidX12TimeCode("ES") // true
```

## Source

[intermodal/validate/isValidX12TimeCode.ts](https://github.com/northguild/gmt/blob/main/packages/gmt/src/intermodal/validate/isValidX12TimeCode.ts)
