Ark.Timeout (ark v0.13.0)

Copy Markdown View Source

Summary

Functions

Formats a millisecond duration as a human-readable string.

Returns the milliseconds until datetime, clamped to [0, 4_294_967_295].

Functions

format(total_ms)

@spec format(non_neg_integer() | :infinity | :hibernate) :: iodata()

Formats a millisecond duration as a human-readable string.

Also accepts :infinity or :hibernate, returning "infinity" for both.

Accepts an optional format argument:

  • :short (default) — compact form, e.g. "1d2h3m"
  • :long — verbose form, e.g. "1 day 2 hours 3 minutes"

Negative values produce a "-" prefix in short format and a "(negative) " prefix in long format.

format(total_ms, format)

@spec format(non_neg_integer() | :infinity | :hibernate, :short | :long) :: iodata()

until(date_time)

@spec until(DateTime.t() | :infinity | :hibernate) ::
  non_neg_integer() | :infinity | :hibernate

Returns the milliseconds until datetime, clamped to [0, 4_294_967_295].

Also accepts :infinity or :hibernate, returning the atom as-is.

An optional now argument overrides the current time (defaults to DateTime.utc_now/0).

until(datetime, now)

@spec until(DateTime.t() | :infinity | :hibernate, DateTime.t()) ::
  non_neg_integer() | :infinity | :hibernate