Centralized UTC clock helpers.
Production code uses these instead of DateTime.utc_now/1 directly so the
second-precision policy and any future test-time clock freezing live in
one place. The clock is swappable via config :dripdrop, :clock, MyClock
where MyClock implements the now/0 callback — useful for freezing
time in flaky timezone or DST tests.
All helpers truncate to the second by design. Sub-second precision is not used in DripDrop schemas and would only invite drift between code paths.
Summary
Functions
Returns the current UTC time truncated to the second.
Returns now() + seconds. Pass a negative value for a past timestamp.
Returns datetime + seconds truncated to the second.
Callbacks
@callback now() :: DateTime.t()
Functions
@spec now() :: DateTime.t()
Returns the current UTC time truncated to the second.
@spec seconds_from_now(integer()) :: DateTime.t()
Returns now() + seconds. Pass a negative value for a past timestamp.
Replaces the recurring DateTime.utc_now(:second) |> DateTime.add(N, :second)
pattern.
@spec shift(DateTime.t(), integer()) :: DateTime.t()
Returns datetime + seconds truncated to the second.