Skip to content

Instantly share code, notes, and snippets.

@spewu
Created May 19, 2013 05:48
Show Gist options
  • Save spewu/5606822 to your computer and use it in GitHub Desktop.
Save spewu/5606822 to your computer and use it in GitHub Desktop.
A nice small wrapper around DateTime. Makes it possible to override the returned DateTime, which is very handy in unit tests
using System;
using System.Diagnostics.CodeAnalysis;
public class SystemTime
{
[SuppressMessage("StyleCop.CSharp.MaintainabilityRules", "SA1401:FieldsMustBePrivate", Justification = "Reviewed. Suppression is OK here.")]
public static Func<DateTime> Now = () => DateTime.Now;
[SuppressMessage("StyleCop.CSharp.MaintainabilityRules", "SA1401:FieldsMustBePrivate", Justification = "Reviewed. Suppression is OK here.")]
public static Func<DateTime> UtcNow = () => DateTime.UtcNow;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment