Using the various Iterator tools:
using Iterators
using IterTools
using Dates
maprepeateduntil(mapfn, condfn, stepfn, initval) =
Iterators.map(mapfn,
Iterators.takewhile(
let done=false
x->(t = done; done = condfn(x); !t)
end,
IterTools.iterated(stepfn, initval)
)
)
iteratetimes(lb, ub, step) =
maprepeateduntil(
Time, ==(ub)∘Time,
Base.Fix1(+, step),
DateTime(Date(now())+lb)
)
with these in place:
julia> iteratetimes(lower_bound, upper_bound, Minute(1)) |> collect
3-element Vector{Time}:
23:59:00
00:00:00
00:01:00
and
julia> iteratetimes(upper_bound, lower_bound, Minute(1)) |> collect |>
x->(display.(extrema(x)); length(x))
00:01:00
23:59:00
1439