<PackageReference Include="Microsoft.Bcl.TimeProvider" Version="8.0.0" />

TimeProvider

public abstract class TimeProvider
Provides an abstraction for time.
public static TimeProvider System { get; }

Gets a TimeProvider that provides a clock based on UtcNow, a time zone based on Local, a high-performance time stamp based on Stopwatch, and a timer based on Timer.

public virtual TimeZoneInfo LocalTimeZone { get; }

Gets a TimeZoneInfo object that represents the local time zone according to this TimeProvider's notion of time.

public virtual long TimestampFrequency { get; }

Gets the frequency of GetTimestamp of high-frequency value per second.

protected TimeProvider()

Initializes the TimeProvider.

public virtual ITimer CreateTimer(TimerCallback callback, object state, TimeSpan dueTime, TimeSpan period)

Creates a new ITimer instance, using TimeSpan values to measure time intervals.

public TimeSpan GetElapsedTime(long startingTimestamp, long endingTimestamp)

Gets the elapsed time between two timestamps retrieved using GetTimestamp.

public TimeSpan GetElapsedTime(long startingTimestamp)

Gets the elapsed time since the startingTimestamp value retrieved using GetTimestamp.

Gets a DateTimeOffset value that is set to the current date and time according to this TimeProvider's notion of time based on GetUtcNow, with the offset set to the LocalTimeZone's offset from Coordinated Universal Time (UTC).

public virtual long GetTimestamp()

Gets the current high-frequency value designed to measure small time intervals with high accuracy in the timer mechanism.

public virtual DateTimeOffset GetUtcNow()

Gets a DateTimeOffset value whose date and time are set to the current Coordinated Universal Time (UTC) date and time and whose offset is Zero, all according to this TimeProvider's notion of time.