Fixing date edge case calculations, closes #179