Celixir.Types.Timestamp (Celixir v0.3.0)

Copy Markdown View Source

CEL timestamp type. Wraps an Elixir DateTime (UTC). Supports RFC3339 parsing, arithmetic with durations, and accessor methods.

Summary

Functions

Add a duration (in microseconds) to a timestamp.

Add a duration (total nanoseconds) to a timestamp, returning {timestamp, total_result_nanos_since_epoch}.

Difference between two timestamps in microseconds.

Difference between two timestamps in nanoseconds.

Get a component of the timestamp, optionally in a timezone.

Creates a timestamp from a DateTime.

Parses an RFC3339 timestamp string.

Subtract a duration (in microseconds) from a timestamp.

Convert to proto representation {seconds, nanos}.

Converts to RFC3339 string.

Returns Unix epoch seconds.

Types

t()

@type t() :: %Celixir.Types.Timestamp{
  datetime: DateTime.t(),
  nanos_remainder: integer()
}

Functions

add(timestamp, duration_us)

Add a duration (in microseconds) to a timestamp.

add_nanos(timestamp, duration_total_ns)

Add a duration (total nanoseconds) to a timestamp, returning {timestamp, total_result_nanos_since_epoch}.

diff(timestamp1, timestamp2)

Difference between two timestamps in microseconds.

diff_nanos(timestamp1, timestamp2)

Difference between two timestamps in nanoseconds.

get_component(ts, component, timezone \\ nil)

Get a component of the timestamp, optionally in a timezone.

new(dt)

Creates a timestamp from a DateTime.

parse(str)

Parses an RFC3339 timestamp string.

subtract(timestamp, duration_us)

Subtract a duration (in microseconds) from a timestamp.

to_proto(timestamp)

Convert to proto representation {seconds, nanos}.

to_string(timestamp)

Converts to RFC3339 string.

to_unix(timestamp)

Returns Unix epoch seconds.