updated date_to_number

Updated date_to_number to use str.split() and save some lines.
Added also an exception to check if the date is valid.