Table of Contents

Interface IClock

Namespace
Tenduke.Core.System
Assembly
Tenduke.Core.dll

Abstraction for System clock related operations.

public interface IClock

Methods

FromTimestamp(long)

Converts a Unix time expressed as the number of seconds that have elapsed since 1970-01-01T00:00:00Z to a System.DateTimeOffset value.

DateTimeOffset FromTimestamp(long timestamp)

Parameters

timestamp long

A Unix time, expressed as the number of seconds that have elapsed since 1970-01-01T00:00:00Z (January 1, 1970, at 12:00 AM UTC). For Unix times before this date, its value is negative.

Returns

DateTimeOffset

A date and time value that represents the same moment in time as the Unix time.

UtcNow()

Gets a System.DateTimeOffset object whose date and time are set to the current Coordinated Universal Time (UTC) date and time and whose offset is System.TimeSpan.Zero.

DateTimeOffset UtcNow()

Returns

DateTimeOffset

An object whose date and time is the current Coordinated Universal Time (UTC) and whose offset is System.TimeSpan.Zero.

WaitAsync(TimeSpan, CancellationToken)

Creates a cancellable task that completes after a specified time interval.

Task WaitAsync(TimeSpan delay, CancellationToken cancellationToken)

Parameters

delay TimeSpan

The time span to wait before completing the returned task, or TimeSpan.FromMilliseconds(-1) to wait indefinitely.

cancellationToken CancellationToken

A cancellation token to observe while waiting for the task to complete.

Returns

Task

A task that represents the time delay.

Exceptions

ArgumentOutOfRangeException

delay represents a negative time interval other than TimeSpan.FromMilliseconds(-1). -or- The delay argument's System.TimeSpan.TotalMilliseconds property is greater than System.Int32.MaxValue.

TaskCanceledException

The task has been canceled.

ObjectDisposedException

The provided cancellationToken has already been disposed.