# isValidRfc2822DateTime

Industry: Core

## Signature

```ts
isValidRfc2822DateTime(value: string): boolean
isValidRfc2822DateTime(value: void | {} | null | undefined): boolean
isValidRfc2822DateTime(value: unknown): value is string
```

Return true when `value` is a real RFC 5322 (RFC 2822) date-time: the date an email `Date:` header carries, such as `Fri, 15 Mar 2024 14:30:00 -0400`.

- True exactly when `parseRfc2822` returns a zoned string for the same value: the validator calls the parser, so the two cannot disagree.
- **Reads what a conformant receiver must**, which is more than the strict `rfc2822DateTime` pattern matches: RFC 5322 §3.3 folding white space, comments, names in any case and a year of more than four digits, and the §4 obsolete syntax (2- and 3-digit years, military and other alphabetic zones). `parseRfc2822` lists each form.
- Checks the calendar as well as the shape. The pattern matches a day that does not exist: `31 Feb`, `29 Feb 2023` and `31 Jun` are false here.
- **The day-of-week must match the date.** RFC 5322 §3.3: "the day-of-week (if included) MUST be the day implied by the date". The pattern does not check it.
- False for an hour above 23, a minute above 59, zone minutes above 59 and an offset of 24 hours or more, all of which the pattern matches. False for a second of 60: GMT rejects leap seconds.
- A value that is not a string, a `String` object included, returns `false`. A `true` result narrows an `unknown` value to `string`.
- Read the value with `parseRfc2822`; write one with `formatRfc2822`.

## Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| `value` | `string` | any value; a string is checked as an RFC 5322 date-time |

## Returns

boolean indicating validity

## Examples

```ts
import { isValidRfc2822DateTime } from "@northguild/gmt/zoned/validate";

isValidRfc2822DateTime("Fri, 15 Mar 2024 14:30:00 -0400") // true
```

## Source

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