Table of Contents

Interface ITimeProvider

Namespace
Vonage.Common
Assembly
Vonage.dll

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

long

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

DateTime

Examples

DateTime now = timeProvider.UtcNow;