# isValidEdifactDateTime

Industry: Intermodal

## Signature

```ts
isValidEdifactDateTime(value: string, format: EdifactDateTimeFormat): boolean
```

Return true when `value` is a UN/EDIFACT `DTM` value (data element 2380) that states a real date and time in a format code with no offset (data element 2379).

- ### Format codes

  | Code | Mask | The directory's description |
  |---|---|---|
  | `203` | `CCYYMMDDHHMM` | "Calendar date including time with minutes" |
  | `204` | `CCYYMMDDHHMMSS` | "Calendar date including time with seconds" |

- True exactly when `parseEdifactDateTime` returns a date-time for the same arguments: the validator and the parser share one core, so the two cannot disagree.
- A value is valid only against its code: `"202406151430"` is a `203` value and not a `204` one.
- Checks the calendar as well as the shape: 31 June, 29 February 2023, hour 24 and second 60 are false.
- False for any other code, a code of another kind included; check a code alone with `isValidEdifactDtmFormat`. False for a non-string argument.

## Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| `value` | `string` | The data element 2380 value (e.g. "202406151430") |
| `format` | `EdifactDateTimeFormat` | The data element 2379 format code |

## Returns

boolean indicating validity

## Related types

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

## Examples

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

isValidEdifactDateTime("202406151430", "203") // true
```

## Source

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