Class TimeProvider
Default implementation of ITimeProvider that returns the actual system time.
public class TimeProvider : ITimeProvider
- Inheritance
-
TimeProvider
- Implements
- Inherited Members
Remarks
For unit testing, consider creating a mock implementation that returns controlled time values.
Properties
Epoch
Gets the current time as a Unix timestamp (seconds since January 1, 1970 UTC).
public 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.
public DateTime UtcNow { get; }
Property Value
Examples
DateTime now = timeProvider.UtcNow;