libfaketime is cool for testing this kind of thing too.
Not as convenient for unit tests cause you have to run the test with LD_PRELOAD.