Tempo.Clock behaviour (Tempo v2.1.1)

Copy Markdown View Source

A behaviour that gives Tempo the current time.

Tempo.utc_now/0, Tempo.now/1, Tempo.utc_today/0 and Tempo.today/1 ask the clock configured under :ex_tempo, :clock, which by default is Tempo.Clock.System and answers with DateTime.utc_now/0. A test pins the time of its own process with Tempo.Clock.Test.put/1, which leaves concurrent tests their own.

Summary

Callbacks

The current time as a DateTime.t/0 in Etc/UTC.

Functions

The clock in use: the calling process's, else the application's, else Tempo.Clock.System.

Callbacks

utc_now()

@callback utc_now() :: DateTime.t()

The current time as a DateTime.t/0 in Etc/UTC.

Functions

clock()

@spec clock() :: module()

The clock in use: the calling process's, else the application's, else Tempo.Clock.System.

Returns

  • The module of the clock in use, one that implements Tempo.Clock.

Examples

iex> Tempo.Clock.clock()
Tempo.Clock.System