JavaScript date period iterator