Refactored to add separate parse_date routine.