Expand description
Time simulation for deterministic testing.
This module provides a simulated time system where time progression is controlled programmatically via step counters and multipliers. This enables deterministic testing of time-dependent code.
Time simulation is based on three components:
- Epoch offset - The base Unix timestamp in milliseconds
- Step counter - The current simulation step
- Step multiplier - How many milliseconds of simulated time pass per step
Simulated time is calculated as: epoch_offset + (step * step_multiplier)
Structs§
- Real
Time - Marker type for temporarily using real system time instead of simulated time.
Functions§
- current_
step - Returns the current simulation step.
- datetime_
local_ now - Returns the current simulated local date and time, or real time if in a
with_real_timecontext. - datetime_
utc_ now - Returns the current simulated UTC date and time, or real time if in a
with_real_timecontext. - epoch_
offset - Returns the current epoch offset in milliseconds.
- instant_
now - Returns a simulated monotonic instant, or real instant if in a
with_real_timecontext. - next_
step - Advances the simulation to the next step.
- now
- Returns the current simulated system time, or real time if in a
with_real_timecontext. - reset_
epoch_ offset - Resets the epoch offset to a new random value.
- reset_
step - Resets the simulation step counter to zero.
- reset_
step_ multiplier - Resets the step multiplier to a new random value.
- set_
step - Sets the current simulation step to the specified value.
- step_
multiplier - Returns the current step multiplier in milliseconds per step.
- with_
real_ time - Executes a function using real system time instead of simulated time.