Interface ITimeProvider
Provides access to the current time. Enables testability by allowing time to be mocked.
public interface ITimeProvider
Remarks
Use dependency injection with this interface to make time-dependent code testable.
See TimeProvider for the default production implementation.
Properties
Epoch
Gets the current time as a Unix timestamp (seconds since January 1, 1970 UTC).
long Epoch { get; }
Property Value
Examples
long timestamp = timeProvider.Epoch;
// Example: 1704067200 (represents 2024-01-01 00:00:00 UTC)
UtcNow
Gets the current UTC date and time.
DateTime UtcNow { get; }
Property Value
Examples
DateTime now = timeProvider.UtcNow;