Method SetTime
- Namespace
- KZDev.SystemClock.PrimeTime.Testing
- Assembly
- KZDev.SystemClock.PrimeTime.Testing.dll
SetTime(DateTimeOffset)
Sets the current UTC time of the clock to the specified value. When the clock is not running, this is the time returned by UtcNowDateTimeOffset and related members.
void SetTime(DateTimeOffset utcTime)
Parameters
utcTimeDateTimeOffsetThe new current UTC time.
Remarks
When utcTime is strictly after the current virtual instant, virtual time advances
forward to that instant using the same march as Advance(TimeSpan) (fire delays,
expiries, and timers at each crossed instant, and ClockEvents once per distinct instant).
Forward SetTime(DateTimeOffset) honors the same local day-time DST policies as
production scheduling where applicable.
When utcTime equals the current virtual instant, no forward march runs; a single
ClockEvents may still be raised. When utcTime is strictly before the
current virtual instant, the instant is assigned without forward marching and without replaying skipped
delay or timer work; ClockEvents is raised once. Permitted backward moves recompute active
day-time NextDueUtc values.
Exceptions
- InvalidOperationException
Thrown when
utcTimeis strictly before the current virtual instant and either the clock is running or any interval timer registration is active.