Skip to content

Commit 9864173

Browse files
author
hhaensel
committed
fix compat with julia < 1.8
1 parent 34f35ce commit 9864173

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/Convert/Convert.jl

+6
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,12 @@ using Dates: Year, Month, Day, Hour, Minute, Week, Period, CompoundPeriod, canon
4949

5050
import ..Core: pyconvert
5151

52+
# patch conversion to Period types for julia <= 1.7
53+
@static if VERSION < v"1.8.0-"
54+
Base.convert(::Type{T}, x::CompoundPeriod) where T<:Period =
55+
isconcretetype(T) ? sum(T, x.periods; init = zero(T)) : throw(MethodError(convert,(T,x)))
56+
end
57+
5258
include("pyconvert.jl")
5359
include("rules.jl")
5460
include("ctypes.jl")

0 commit comments

Comments
 (0)