# `QuackDB.NanosecondTimestamp`
[🔗](https://github.com/elixir-vibe/quackdb/blob/main/lib/quack_db/nanosecond_timestamp.ex#L1)

DuckDB `TIMESTAMP_NS` value stored as nanoseconds since the Unix epoch.

Elixir's `NaiveDateTime` type stores microseconds, so this struct preserves
DuckDB's nanosecond precision while offering conversion to a truncated
`NaiveDateTime`.

# `t`

```elixir
@type t() :: %QuackDB.NanosecondTimestamp{nanoseconds: integer()}
```

# `from_naive_datetime`

```elixir
@spec from_naive_datetime(NaiveDateTime.t()) :: t()
```

Builds a `TIMESTAMP_NS` value from an Elixir `NaiveDateTime`.

# `new`

```elixir
@spec new(integer()) :: t()
```

Builds a `TIMESTAMP_NS` value from nanoseconds since the Unix epoch.

# `to_integer`

```elixir
@spec to_integer(t()) :: integer()
```

Returns the stored nanoseconds since the Unix epoch.

# `to_naive_datetime`

```elixir
@spec to_naive_datetime(t()) :: NaiveDateTime.t()
```

Converts to an Elixir `NaiveDateTime`, truncating sub-microsecond precision.

---

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