Factor out parser for time format