Skip to content

Commit

Permalink
Deprecate vectorized Dates.format methods in favor of compact broadca…
Browse files Browse the repository at this point in the history
…st syntax.
  • Loading branch information
Sacha0 committed Aug 10, 2017
1 parent 62c3b22 commit 96b1297
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 13 deletions.
4 changes: 2 additions & 2 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -299,8 +299,8 @@ Deprecated or removed
* Calling `union` with no arguments is deprecated; construct an empty set with an appropriate
element type using `Set{T}()` instead ([#23144]).

* Vectorized `DateTime` and `Date` methods have been deprecated in favor of dot-syntax
([#CATS]).
* Vectorized `DateTime`, `Date`, and `format` methods have been deprecated in favor of
dot-syntax ([#CATS]).

* `Base.cpad` has been removed; use an appropriate combination of `rpad` and `lpad`
instead ([#23187]).
Expand Down
8 changes: 0 additions & 8 deletions base/dates/io.jl
Original file line number Diff line number Diff line change
Expand Up @@ -557,11 +557,3 @@ function Base.string(dt::Date)
dd = lpad(d, 2, "0")
return "$yy-$mm-$dd"
end

# vectorized
function format(Y::AbstractArray{<:TimeType}, f::AbstractString; locale::Locale=ENGLISH)
format(Y, DateFormat(f, locale))
end
function format(Y::AbstractArray{T}, df::DateFormat=default_format(T)) where T<:TimeType
return reshape([format(y, df) for y in Y], size(Y))
end
8 changes: 7 additions & 1 deletion base/deprecated.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1584,7 +1584,7 @@ for op in (:exp, :exp2, :exp10, :log, :log2, :log10,
@eval @deprecate ($op)(x::AbstractSparseVector{<:Number,<:Integer}) ($op).(x)
end

# deprecate reamining vectorized methods from Base.Dates
# deprecate remaining vectorized methods from Base.Dates
@eval Dates @deprecate(
DateTime(Y::AbstractArray{<:AbstractString}, f::AbstractString; locale::Locale=ENGLISH),
DateTime.(Y, f; locale=locale) )
Expand All @@ -1597,6 +1597,12 @@ end
@eval Dates @deprecate(
Date(Y::AbstractArray{<:AbstractString}, df::DateFormat=ISODateFormat),
Date.(Y, df) )
@eval Dates @deprecate(
format(Y::AbstractArray{<:TimeType}, f::AbstractString; locale::Locale=ENGLISH),
format.(Y, f; locale=locale) )
@eval Dates @deprecate(
format(Y::AbstractArray{T}, df::DateFormat=default_format(T)) where {T<:TimeType},
format.(Y, df) )

# PR #22182
@deprecate is_apple Sys.isapple
Expand Down
3 changes: 1 addition & 2 deletions test/dates/io.jl
Original file line number Diff line number Diff line change
Expand Up @@ -328,8 +328,7 @@ dr2 = [Dates.Date(2000) : Dates.Date(2000, 1, 10);]
@test Dates.DateTime.(dr) == Dates.DateTime.(dr2)
@test Dates.DateTime.(dr, "yyyy-mm-dd") == Dates.DateTime.(dr2)

@test Dates.format(dr2) == dr
@test Dates.format(dr2, "yyyy-mm-dd") == dr
@test Dates.format.(dr2, "yyyy-mm-dd") == dr

@test typeof(Dates.Date.(dr)) == Array{Date, 1}

Expand Down

0 comments on commit 96b1297

Please sign in to comment.