Skip to content

Instantly share code, notes, and snippets.

@ChrisMcKee
Created January 4, 2013 11:35
Show Gist options
  • Select an option

  • Save ChrisMcKee/4451940 to your computer and use it in GitHub Desktop.

Select an option

Save ChrisMcKee/4451940 to your computer and use it in GitHub Desktop.
Freezable DateTime replacement
namespace Core
{
using System;
public static class SystemTime
{
public static Func<DateTime> Now = () => DateTime.Now;
public static void Freeze()
{
var frozenDate = new DateTime(Now().Year, Now().Month, Now().Day, Now().Hour, Now().Minute, Now().Second);
Now = () => frozenDate;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment