Fixes bug with invalid date in parseDate function