# rfc3339DateTime

Industry: Core

```ts
const rfc3339DateTime: RegExp = /^(\d{4})-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01])[Tt ](0[0-9]|1[0-9]|2[0-3]):([0-5][0-9]):([0-5][0-9])(\.[0-9]{1,9})?(Z|z|[+-](?:[01][0-9]|2[0-3]):[0-5][0-9])$/;
```

RegExp matching an RFC 3339 §5.6 date-time: ISO 8601 with a mandatory offset (`Z` or `±HH:MM`).

## Examples

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

```ts
rfc3339DateTime.test("2024-03-15T14:30:00-04:00") // true
rfc3339DateTime.test("2024-03-15t14:30:00z") // true
rfc3339DateTime.test("2024-03-15 14:30:00Z") // true (space separator)
rfc3339DateTime.test("2024-03-15T14:30:00") // false (no offset)
rfc3339DateTime.test("2024-03-15T14:30:00+00:00[UTC]") // false (bracketed zone)
rfc3339DateTime.test("2024-3-15T14:30:00Z") // false (unpadded)
rfc3339DateTime.test("2024-03-15T14:30:00+24:00") // false (offset hour out of range)
rfc3339DateTime.test("2016-12-31T23:59:60Z") // false (leap second; GMT rejects it)
```

## Source

[regex/rfc-3339.ts](https://github.com/northguild/gmt/blob/main/packages/gmt/src/regex/rfc-3339.ts)
