Minor refactoring to improve date error handling.