New implementation of isBefore/isSame/isAfter

This has been discussed in #1877 and #1772.

I need to add some tests. The existing ones pass though :)