Refactored time parsing using regex