Skip to content

Instantly share code, notes, and snippets.

@ansariabr
Last active December 18, 2019 16:21
Show Gist options
  • Save ansariabr/da84f6b70ffd92a3ddbc08280d42fbaf to your computer and use it in GitHub Desktop.
Save ansariabr/da84f6b70ffd92a3ddbc08280d42fbaf to your computer and use it in GitHub Desktop.
A wrapper on top of DateTimeOffset
public struct DateTimeOffsetWrapper
{
private static DateTimeOffset? _dateTimeOffset;
public static DateTimeOffset Now => _dateTimeOffset ?? DateTimeOffset.Now;
/// <summary>
/// This method can be used to initialize our internal DateTimeOffset object to the desired date and time
/// </summary>
/// <param name="dateTimeOffset">Desired date and time</param>
public static void SetDateTimeOffset(DateTimeOffset dateTimeOffset)
{
_dateTimeOffset = dateTimeOffset;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment