-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #29509 from JuliaLang/jq/dates
Grab bag of Dates fixes
- Loading branch information
Showing
4 changed files
with
88 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,67 @@ | ||
# This file is a part of Julia. License is MIT: https://julialang.org/license | ||
|
||
using Base: @deprecate, depwarn | ||
|
||
# 1.0 deprecations | ||
function (+)(x::AbstractArray{<:TimeType}, y::GeneralPeriod) | ||
# depwarn("non-broadcasted arithmetic is deprecated for Dates.TimeType; use broadcasting instead", nothing) | ||
x .+ y | ||
end | ||
function (+)(x::StridedArray{<:GeneralPeriod}, y::TimeType) | ||
# depwarn("non-broadcasted arithmetic is deprecated for Dates.TimeType; use broadcasting instead", nothing) | ||
x .+ y | ||
end | ||
function (+)(y::GeneralPeriod, x::AbstractArray{<:TimeType}) | ||
# depwarn("non-broadcasted arithmetic is deprecated for Dates.TimeType; use broadcasting instead", nothing) | ||
x .+ y | ||
end | ||
function (+)(y::TimeType, x::StridedArray{<:GeneralPeriod}) | ||
# depwarn("non-broadcasted arithmetic is deprecated for Dates.TimeType; use broadcasting instead", nothing) | ||
x .+ y | ||
end | ||
function (-)(x::AbstractArray{<:TimeType}, y::GeneralPeriod) | ||
# depwarn("non-broadcasted arithmetic is deprecated for Dates.TimeType; use broadcasting instead", nothing) | ||
x .- y | ||
end | ||
function (-)(x::StridedArray{<:GeneralPeriod}, y::TimeType) | ||
# depwarn("non-broadcasted arithmetic is deprecated for Dates.TimeType; use broadcasting instead", nothing) | ||
x .- y | ||
end | ||
|
||
# TimeType, AbstractArray{TimeType} | ||
function (-)(x::AbstractArray{T}, y::T) where {T<:TimeType} | ||
# depwarn("non-broadcasted arithmetic is deprecated for Dates.TimeType; use broadcasting instead", nothing) | ||
x .- y | ||
end | ||
function (-)(y::T, x::AbstractArray{T}) where {T<:TimeType} | ||
# depwarn("non-broadcasted arithmetic is deprecated for Dates.TimeType; use broadcasting instead", nothing) | ||
y .- x | ||
end | ||
|
||
for (op, Ty, Tz) in ((:*, Real, :P), | ||
(:/, :P, Float64), (:/, Real, :P)) | ||
@eval begin | ||
function ($op)(X::StridedArray{P}, y::$Ty) where P<:Period | ||
# depwarn("non-broadcasted arithmetic is deprecated for Dates.TimeType; use broadcasting instead", nothing) | ||
Z = similar(X, $Tz) | ||
for (Idst, Isrc) in zip(eachindex(Z), eachindex(X)) | ||
@inbounds Z[Idst] = ($op)(X[Isrc], y) | ||
end | ||
return Z | ||
end | ||
end | ||
end | ||
|
||
function (+)(x::StridedArray{<:GeneralPeriod}) | ||
# depwarn("non-broadcasted operations are deprecated for Dates.TimeType; use broadcasting instead", nothing) | ||
x | ||
end | ||
|
||
for op in (:+, :-) | ||
@eval begin | ||
function ($op)(X::StridedArray{<:GeneralPeriod}, Y::StridedArray{<:GeneralPeriod}) | ||
# depwarn("non-broadcasted arithmetic is deprecated for Dates.TimeType; use broadcasting instead", nothing) | ||
reshape(CompoundPeriod[($op)(x, y) for (x, y) in zip(X, Y)], promote_shape(size(X), size(Y))) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters