Refactor date segment functions