Add error handling for invalid dates