This is preliminary documentation and is subject to change.

DateTimeProvider Class

A date and time provider, that can be used to simulate a certain date or time
When no mock date/time is set, it returns the datetime values from the system, otherwise the set value. The mock values does not change or reflect time passing.

Definition

Namespace: MoreDateTime
Assembly: MoreDateTime (in MoreDateTime.dll) Version: 1.3.0
C#
public class DateTimeProvider : IDateTimeProvider
Inheritance
Object    DateTimeProvider
Implements
IDateTimeProvider

Constructors

DateTimeProvider Initializes a new instance of the DateTimeProvider class.

Properties

Current Gets the current DateTimeProvider
Now Gets the current DateTime (or the mock value if set)
Today Gets the date part of the current DateTime with the time set to 00:00:00 (or the mock value if set)
UtcNow Gets the current UTC DateTime (or the mock value if set)
UtcToday Gets the date part of the current UTC DateTime with the time set to 00:00:00 (or the mock value if set)

Methods

SetMockDateTime Sets the mock date time. This substitutes delivering the current date time from the system. Use for testing and verification.
SetUtcHandling Sets how UTC is handled by the Now property, if true then Now is returning UTC time

See Also