QuackDB.NanosecondTimestamp (quackdb v0.4.0)

Copy Markdown View Source

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.

Summary

Functions

Builds a TIMESTAMP_NS value from an Elixir NaiveDateTime.

Builds a TIMESTAMP_NS value from nanoseconds since the Unix epoch.

Returns the stored nanoseconds since the Unix epoch.

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

Types

t()

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

Functions

from_naive_datetime(value)

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

Builds a TIMESTAMP_NS value from an Elixir NaiveDateTime.

new(nanoseconds)

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

Builds a TIMESTAMP_NS value from nanoseconds since the Unix epoch.

to_integer(nanosecond_timestamp)

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

Returns the stored nanoseconds since the Unix epoch.

to_naive_datetime(nanosecond_timestamp)

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

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