Refactored date logic.  Added doctests