@@ -82,12 +82,6 @@ for op in (:.+, :.-)
8282 ($ op){P<: GeneralPeriod }(y:: TimeType , x:: StridedArray{P} ) = ($ op)(x,y)
8383 ($ op_){T<: TimeType ,P<: GeneralPeriod }(x:: StridedArray{P} , y:: T ) = ($ op)(x,y)
8484 ($ op_){P<: GeneralPeriod }(y:: TimeType , x:: StridedArray{P} ) = ($ op)(x,y)
85-
86- # AbstractArray{TimeType}, StridedArray{GeneralPeriod}
87- ($ op_){T<: TimeType ,P<: GeneralPeriod }(x:: Range{T} , y:: StridedArray{P} ) = ($ op_)(collect (x),y)
88- ($ op_){T<: TimeType ,P<: GeneralPeriod }(x:: AbstractArray{T} , y:: StridedArray{P} ) =
89- reshape (TimeType[($ op_)(x[i],y[i]) for i in eachindex (x, y)], promote_shape (size (x),size (y)))
90- ($ op_){T<: TimeType ,P<: GeneralPeriod }(y:: StridedArray{P} , x:: AbstractArray{T} ) = ($ op_)(x,y)
9185 end
9286end
9387
10094# AbstractArray{TimeType}, AbstractArray{TimeType}
10195(- ){T<: TimeType }(x:: OrdinalRange{T} , y:: OrdinalRange{T} ) = collect (x) - collect (y)
10296(- ){T<: TimeType }(x:: Range{T} , y:: Range{T} ) = collect (x) - collect (y)
103- (- ){T<: TimeType }(x:: AbstractArray{T} , y:: Range{T} ) = y - collect (x)
104- (- ){T<: TimeType }(x:: Range{T} , y:: AbstractArray{T} ) = collect (x) - y
105- (- ){T<: TimeType }(x:: AbstractArray{T} , y:: AbstractArray{T} ) =
106- reshape (Period[x[i] - y[i] for i in eachindex (x, y)], promote_shape (size (x),size (y)))
97+
98+ # promotion rules
99+
100+ for (op,F) in ((:+ , Base. AddFun),
101+ (:- , Base. SubFun),
102+ (:.+ , Base. DotAddFun),
103+ (:.- , Base. DotSubFun))
104+ @eval begin
105+ Base. promote_op {P<:Period} (:: $F , :: Type{P} , :: Type{P} ) = P
106+ Base. promote_op {P1<:Period,P2<:Period} (:: $F , :: Type{P1} , :: Type{P2} ) = CompoundPeriod
107+ Base. promote_op {D<:Date} (:: $F , :: Type{D} , :: Type{D} ) = Day
108+ Base. promote_op {D<:DateTime} (:: $F , :: Type{D} , :: Type{D} ) = Millisecond
109+ end
110+ end
111+
112+ for (op,F) in ((:/ , Base. RDivFun),
113+ (:% , Base. RemFun),
114+ (:div , Base. IDivFun),
115+ (:mod , Base. ModFun),
116+ (:./ , Base. DotRDivFun),
117+ (:.% , Base. DotRemFun))
118+ @eval begin
119+ Base. promote_op {P<:Period} (:: $F , :: Type{P} , :: Type{P} ) = typeof ($ op (1 ,1 ))
120+ Base. promote_op {P<:Period,R<:Real} (:: $F , :: Type{P} , :: Type{R} ) = P
121+ end
122+ end
0 commit comments