Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

intersect on StepRange{DateTime} results in MethodError #39810

Closed
sdl1 opened this issue Feb 24, 2021 · 1 comment
Closed

intersect on StepRange{DateTime} results in MethodError #39810

sdl1 opened this issue Feb 24, 2021 · 1 comment
Labels
domain:dates Dates, times, and the Dates stdlib module

Comments

@sdl1
Copy link

sdl1 commented Feb 24, 2021

julia> using Dates

julia> dt = DateTime(2018, 1, 1)
2018-01-01T00:00:00

julia> dt = DateTime(2018, 1, 1);

julia> a = dt:Hour(1):dt + Hour(5);

julia> b = dt + Hour(2):Hour(1):dt + Hour(7);

julia> intersect(a,b)
ERROR: MethodError: no method matching rem(::Millisecond, ::Hour)
Closest candidates are:
  rem(::Any, ::Any, ::RoundingMode{:ToZero}) at div.jl:67
  rem(::Any, ::Any, ::RoundingMode{:Down}) at div.jl:68
  rem(::Any, ::Any, ::RoundingMode{:Up}) at div.jl:69
  ...
Stacktrace:
 [1] intersect(::StepRange{DateTime,Hour}, ::StepRange{DateTime,Hour}) at ./range.jl:852
 [2] top-level scope at REPL[7]:1

julia> intersect(collect(a), b) # Works, but returns a vector rather than a StepRange
4-element Array{DateTime,1}:
 2018-01-01T02:00:00
 2018-01-01T03:00:00
 2018-01-01T04:00:00
 2018-01-01T05:00:00

julia> @which intersect(a, b)
intersect(r::StepRange, s::StepRange) in Base at range.jl:822

julia> @which intersect(collect(a), b)
intersect(itr, itrs...) in Base at array.jl:2566
julia> versioninfo()
Julia Version 1.5.2
Commit 539f3ce943 (2020-09-23 23:17 UTC)
Platform Info:
  OS: macOS (x86_64-apple-darwin18.7.0)
  CPU: Intel(R) Core(TM) i7-8850H CPU @ 2.60GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-9.0.1 (ORCJIT, skylake)
Environment:
  JULIA_MPI_PATH = /usr/local/Cellar/open-mpi/4.0.3/
@laborg
Copy link
Contributor

laborg commented Feb 14, 2022

Fixed by #43360

julia> using Dates

julia> dt = DateTime(2018, 1, 1)
2018-01-01T00:00:00

julia> dt = DateTime(2018, 1, 1);

julia> a = dt:Hour(1):dt + Hour(5);

julia> b = dt + Hour(2):Hour(1):dt + Hour(7);

julia> intersect(a,b)
DateTime("2018-01-01T02:00:00"):Hour(1):DateTime("2018-01-01T05:00:00")

@laborg laborg closed this as completed Feb 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
domain:dates Dates, times, and the Dates stdlib module
Projects
None yet
Development

No branches or pull requests

3 participants