Created
January 4, 2013 11:35
-
-
Save ChrisMcKee/4451940 to your computer and use it in GitHub Desktop.
Freezable DateTime replacement
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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