Updated function for parse date