PR 1360 revived: Add clamp function

https://github.com/D-Programming-Language/phobos/pull/1360

As original author did not respond to reviewer comments for some time, I have made necessary changes and created new PR for it.
Do the tests already import std.datetime? Otherwise, that's a rather large chunk of code to be pulled in.