Interface IClock
Represents a clock which can return the current time as an Instant.
Since 1.0.x
Availability net35-Client
Namespace: NodaTime
Assembly: NodaTime.dll
Syntax
public interface IClock
Remarks
IClock is intended for use anywhere you need to have access to the current time.
Although it's not strictly incorrect to call
SystemClock.Instance.Now
directly,
in the same way as you might call System.DateTime.UtcNow, it's strongly discouraged
as a matter of style for production code. We recommend providing an instance of IClock
to anything that needs it, which allows you to write tests using the stub clock in the NodaTime.Testing
assembly (or your own implementation).
Properties
Now
Gets the current Instant on the time line according to this clock.
Since 1.0.x
Availability net35-Client
Declaration
Instant Now { get; }
Property Value
Type | Description |
---|---|
Instant |
See Also
NodaTime.Testing.StubClock