# x12TimeCodeZone

Industry: Intermodal

## Signature

```ts
x12TimeCodeZone(timeCode: X12ZoneTimeCode): X12NamedZone
x12TimeCodeZone(timeCode: unknown): X12NamedZone | null
```

Read the zone an X12 time code (data element 623) names.

- Data element 623 is the code beside the date (element 373) and time (element 337) of an X12 `AT7`, `G62` or `DTM` segment. 25 of its 56 codes name a zone and state no offset; this function reads those. Codes are 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. ### Time codes that name a zone

  | Codes | The dictionary's definition | `zone` |
  |---|---|---|
  | `AD`, `AS`, `AT` | "Alaska Daylight Time", "Alaska Standard Time", "Alaska Time" | `Alaska` |
  | `CD`, `CS`, `CT` | "Central Daylight Time", "Central Standard Time", "Central Time" | `Central` |
  | `ED`, `ES`, `ET` | "Eastern Daylight Time", "Eastern Standard Time", "Eastern Time" | `Eastern` |
  | `HD`, `HS`, `HT` | "Hawaii-Aleutian Daylight Time", "Hawaii-Aleutian Standard Time", "Hawaii-Aleutian Time" | `Hawaii-Aleutian` |
  | `MD`, `MS`, `MT` | "Mountain Daylight Time", "Mountain Standard Time", "Mountain Time" | `Mountain` |
  | `ND`, `NS`, `NT` | "Newfoundland Daylight Time", "Newfoundland Standard Time", "Newfoundland Time" | `Newfoundland` |
  | `PD`, `PS`, `PT` | "Pacific Daylight Time", "Pacific Standard Time", "Pacific Time" | `Pacific` |
  | `TD`, `TS`, `TT` | "Atlantic Daylight Time", "Atlantic Standard Time", "Atlantic Time" | `Atlantic` |
  | `LT` | "Local Time" | `Local` |

- **The result is a zone name, not an offset.** X12 states no offset for these codes and GMT holds no registry of places, so the caller maps the name to an IANA zone. A caller might choose `America/New_York` for `Eastern`; the choice is the caller's. Resolve the local date-time in that zone with `resolveLocal`.
- **`daylight` is `true` for a `D` code, `false` for an `S` code and `null` for a `T` code**, which says neither: the date decides. Both members are always present.
- **`LT` is local to the event** and returns `{ zone: "Local", daylight: null }`. The place is elsewhere in the message, so the caller supplies its zone.
- **An offset code returns `null`**: `01`–`29`, `UT` and `GM` state an offset and name no zone. Read one with `x12TimeCodeOffset`.
- **`TS`, `TT`, `CD` and `MD` are codes of data element 1250 too**, with unrelated meanings: here they are Atlantic Standard, Atlantic, Central Daylight and Mountain Daylight Time; there `TS` is the format `HHMMSS`. Pass a time code here and a format qualifier to the `parseX12…` functions.
- **For a code that arrives as a string**, call `classifyX12TimeCode` first: its `"zone"` result carries the code narrowed to this function's parameter.
- Matching is exact: two characters, upper case, no padding. Each call returns a new object. Returns `null` for a value outside `X12ZoneTimeCode`: an offset code, a string that is not one of the 56, or a non-string.

## Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| `timeCode` | `X12ZoneTimeCode` | X12 data element 623 time code (e.g. "ES") |

## Returns

`{ zone, daylight }`; null only for a value outside X12ZoneTimeCode

## Types

### X12NamedZone

The zone an X12 data element 623 time code names: the result of `x12TimeCodeZone`. X12 states no offset for a named code, so the result carries none.

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

| Member | Type | Description |
| --- | --- | --- |
| `zone` | `string` | X12's own name for the zone, as its definition writes it: `Alaska`, `Central`, `Eastern`, `Hawaii-Aleutian`, `Mountain`, `Newfoundland`, `Pacific` or `Atlantic`, and `Local` for `LT`. It is a name, not an IANA identifier and not an offset: the caller maps it to a zone. |
| `daylight` | `boolean` \| `null` | Whether the code says daylight time. `true` for a `D` code (`ED`), `false` for an `S` code (`ES`), and `null` for a code that says neither (`ET`, `LT`), where the date decides. |

## Related types

- [`X12ZoneTimeCode`](/gmt/reference/types/X12ZoneTimeCode/)

## Examples

```ts
import { x12TimeCodeZone } from "@northguild/gmt/intermodal/parse";

x12TimeCodeZone("ES") // { zone: "Eastern", daylight: false }
```

## Source

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