Refactor firstDateTime logic