You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
well, I think it still relevant, but not sure about there is some re-usable codebase about the resampling function recently added or not.
About the API, maybe a factory function to create iterator object that obey the iterator protocol in internal implementation, then return the TimeArray for the public API.
maybe you could put your idea about the API design first here.
Thanks! Here's a rough API idea: time_slots(start, stop, interval; from=Time(8,45), to=Time(13,45))
returning a TimeArray. Does that direction make sense?
Thanks! Here's a rough API idea: time_slots(start, stop, interval; from=Time(8,45), to=Time(13,45))
returning a TimeArray. Does that direction make sense?
oh, I just got an idea: filter(∈(Time(8,45):Time(13,45)), DateTime(2026, 1, 1):Minute(15):DateTime(2026, 12, 31))
Do this style make sense to you?
Also, it' fine for me to provide several styles of API.
That's a clean approach! So the idea would be to make Time ranges work with ∈ and step through DateTime ranges essentially making the filtering composable with Julia's existing iteration protocol rather than a custom API. I'll prototype this and share what I come up with.
julia> using Dates
julia> result = filter(∈(Time(8,45):Minute(15):Time(13,45)),
DateTime(2026,1,1):Minute(15):DateTime(2026,1,10))
ERROR: promotion of types Time and DateTime failed to change any arguments
Stacktrace:
[1] error(::String, ::String, ::String)
@ Base .\error.jl:54
[2] sametype_error(input::Tuple{Time, DateTime})
@ Base .\promotion.jl:428
[3] not_sametype(x::Tuple{Time, DateTime}, y::Tuple{Time, DateTime})
@ Base .\promotion.jl:422
[4] promote
@ .\promotion.jl:405 [inlined]
[5] ==(x::Time, y::DateTime)
@ Dates C:\Users\RadhaKunjBalram\.julia\juliaup\julia-1.12.5+0.x64.w64.mingw32\share\julia\stdlib\v1.12\Dates\src\types.jl:475
[6] in
@ .\operators.jl:1362 [inlined]
[7] Fix
@ .\operators.jl:1194 [inlined]
[8] filter(f::Base.Fix2{typeof(in), StepRange{Time, Minute}}, a::StepRange{DateTime, Minute})
@ Base .\array.jl:2952
[9] top-level scope
@ REPL[5]:1
julia>
Prototyped the core logic. The key insight is that ∈ fails when comparing Time and DateTime directly due to type promotion, but extracting Time(dt) from each DateTime solves it cleanly:
time_slots(start, stop, interval; from=Time(8,45), to=Time(13,45)) # could returns a lazy iterator that do not materialized the vector at first?time_slots(range_object; from=..., to=...)
when(ta, time_slots(; from=..., to=...)) # this returns a new TimeArray
Thanks!,
I'll implement all three. The when variant is especially useful for filtering existing TimeArrays by time-of-day very composable with real data. Will start with basic time_slots and share a draft PR soon
Activity
anurag-mds commentedon Mar 1, 2026
Hi @iblislin! I've been contributing to
TimeSeries.jl and I'm interested in working
on this issue.
Could you clarify a few things before I start:
functions I should build on top of?
Happy to take this on if it's still needed!
iblislin commentedon Mar 3, 2026
well, I think it still relevant, but not sure about there is some re-usable codebase about the resampling function recently added or not.
About the API, maybe a factory function to create iterator object that obey the iterator protocol in internal implementation, then return the TimeArray for the public API.
maybe you could put your idea about the API design first here.
anurag-mds commentedon Mar 3, 2026
Thanks! Here's a rough API idea:
time_slots(start, stop, interval; from=Time(8,45), to=Time(13,45))returning a
TimeArray. Does that direction make sense?iblislin commentedon Mar 4, 2026
oh, I just got an idea:
filter(∈(Time(8,45):Time(13,45)), DateTime(2026, 1, 1):Minute(15):DateTime(2026, 12, 31))Do this style make sense to you?
Also, it' fine for me to provide several styles of API.
anurag-mds commentedon Mar 4, 2026
That's a clean approach! So the idea would be to make Time ranges work with ∈ and step through DateTime ranges essentially making the filtering composable with Julia's existing iteration protocol rather than a custom API. I'll prototype this and share what I come up with.
anurag-mds commentedon Mar 9, 2026
Prototyped the core logic. The key insight is that ∈ fails when comparing Time and DateTime directly due to type promotion, but extracting Time(dt) from each DateTime solves it cleanly:
Planning to wrap this as:
juliatime_slots(start, stop, interval; from=Time(8,45), to=Time(13,45))returning a TimeArray. Does this direction look good to proceed with a PR?
iblislin commentedon Mar 10, 2026
ah, fine
Maybe we could have following public APIs:
If you have more ideas, fine to put them here.
anurag-mds commentedon Mar 10, 2026
Thanks!,
I'll implement all three. The
whenvariant is especially useful for filtering existingTimeArraysby time-of-day very composable with real data. Will start with basictime_slotsand share a draft PR soonAdd time_slots and TimeWindow for issue JuliaStats#481
Add time_slots and TimeWindow for issue JuliaStats#481
Add time_slots and TimeWindow for issue #481 (#553)