refactoring of time parsing