Refactored date parsing