A testable alternative to DateTime.Now
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.nuget
System.Clock
Test.System.Clock
build
common
.gitattributes
.gitignore
System.Clock.sln
license.txt
readme.md

readme.md

System.Clock

A testable alternative to DateTime.Now

Build status

Quick Start

PM> Install-Package System.Clock

Now use System.Clock.Now instead of System.DateTime.Now

Examples

//freeze time
System.Clock.Freeze(); 

//freeze at a specific time
System.Clock.Freeze(new DateTime(2012, 12, 21)); 

//return time to the present
System.Clock.Unfreeze(); 

Inspired by Ayende Rahien's SystemTime