# isValidEdifactDtmFormat

Industry: Intermodal

## Signature

```ts
isValidEdifactDtmFormat(format: unknown): format is EdifactDtmFormat
```

Return 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) and `719` (a period of date-times). `classifyEdifactDtmFormat` names 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`, `713` and `717`. UN/EDIFACT does not say which century `YY` belongs to; read such a value with `parseDateWithPattern` or `parseDateTimeWithPattern`, a `yy` pattern and its `yearWindow` option.
- `209` and `404` (a time with an offset and no date) and `406` (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 date `105`, `210`, `307`, `308`, the time spans `501`–`503`, `711`, the partial values, the weekday period `720` and the quantities (`801` and up).
- Matching is exact: `" 203"`, `"0203"` and the number `203` are 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

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

## Returns

boolean indicating validity

## Types

### 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](http://web.archive.org/web/20240303123657/https://service.unece.org/trade/untdid/d21b/tred/tred2379.htm) and [D.22B](http://web.archive.org/web/20260311101223/https://service.unece.org/trade/untdid/d22b/tred/tred2379.htm) 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.

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

```ts
"102" | "718" | EdifactDateTimeFormat | "719" | EdifactOffsetDateTimeFormat | EdifactTimeFormat
```

## Related types

- [`EdifactDateFormat`](/gmt/reference/types/EdifactDateFormat/)
- [`EdifactTimeFormat`](/gmt/reference/types/EdifactTimeFormat/)
- [`EdifactDateTimeFormat`](/gmt/reference/types/EdifactDateTimeFormat/)
- [`EdifactOffsetDateTimeFormat`](/gmt/reference/types/EdifactOffsetDateTimeFormat/)
- [`EdifactDatePeriodFormat`](/gmt/reference/types/EdifactDatePeriodFormat/)
- [`EdifactDateTimePeriodFormat`](/gmt/reference/types/EdifactDateTimePeriodFormat/)

## Examples

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

isValidEdifactDtmFormat("203") // true
```

## Source

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