# `Spectral.Codec.NaiveDateTime`
[🔗](https://github.com/andreashasse/spectral/blob/main/lib/spectral/codec/naive_date_time.ex#L1)

Built-in codec for `NaiveDateTime.t()`.

Encodes `NaiveDateTime` structs to ISO 8601 strings without an offset
(e.g. `"2023-04-01T12:30:00"`) and decodes them back. Handles `:json` and
`:binary_string` formats (returning a binary string) and `:string` format
(returning a charlist).

The schema is a `string` with a `pattern`, not `format: "date-time"`: JSON
Schema's `date-time` format requires an offset, which a `NaiveDateTime` lacks.

## Registration

Registered automatically when the `:spectral` application starts. To use a
different codec for `NaiveDateTime.t()`, set it in `config :spectra, :codecs`;
user-configured codecs take precedence over the built-ins.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
