Open
Description
For example:
using Dates
(Dates.Hour(1):Dates.Hour(1):Dates.Hour(2))[1:0]
Errors with
ERROR: MethodError: no method matching copysign(::Hour, ::Hour)
The function `copysign` exists, but no method is defined for this combination of argument types.
Closest candidates are:
copysign(::Float64, ::Float64)
@ Base floatfuncs.jl:5
copysign(::Float64, ::Real)
@ Base floatfuncs.jl:8
copysign(::Float32, ::Float32)
@ Base floatfuncs.jl:6
...
Stacktrace:
[1] getindex(r::StepRange{Hour, Hour}, s::UnitRange{Int64})
@ Base .\range.jl:1029
[2] top-level scope
A possible fix would be to define Base.copysign
on TimePeriod
. The below works
import Dates.value
Base.copysign(x::T, y::T) where T<:TimePeriod = T(copysign(value(x), value(y)))
(Dates.Hour(1):Dates.Hour(1):Dates.Hour(2))[1:0]