# `SiteMaps.Date`
[🔗](https://github.com/marcosgz/site_maps_ex/blob/v0.1.0/lib/site_maps/date.ex#L1)

W3C datetime normalization and formatting for sitemap dates.

A `NaiveDateTime` is treated as UTC, a `DateTime` or ISO 8601 string keeps its offset and a
`Date` is written as `YYYY-MM-DD`. Sub-second precision is dropped.

# `t`

```elixir
@type t() :: DateTime.t() | Date.t()
```

# `cast!`

```elixir
@spec cast!(term(), atom()) :: t() | nil
```

Casts a value to a `DateTime` or `Date`.

Accepts `DateTime`, `NaiveDateTime` (as UTC), `Date` and ISO 8601 strings. `nil` stays `nil`.
Raises `ArgumentError` for anything else, including integers.

# `w3c`

```elixir
@spec w3c(DateTime.t() | NaiveDateTime.t() | Date.t()) :: String.t()
```

Formats a date in the W3C datetime format.

    iex> SiteMaps.Date.w3c(~U[2026-03-01 10:00:00.123Z])
    "2026-03-01T10:00:00+00:00"

    iex> SiteMaps.Date.w3c(~N[2026-03-01 10:00:00])
    "2026-03-01T10:00:00+00:00"

    iex> SiteMaps.Date.w3c(~D[2026-03-01])
    "2026-03-01"

---

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