Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,9 @@ 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`, `Date`, and `format` methods have been deprecated in favor of
dot-syntax ([#23207]).

* `Base.cpad` has been removed; use an appropriate combination of `rpad` and `lpad`
instead ([#23187]).

Expand Down Expand Up @@ -1156,3 +1159,5 @@ Command-line option changes
[#23117]: https://github.com/JuliaLang/julia/issues/23117
[#23144]: https://github.com/JuliaLang/julia/issues/23144
[#23157]: https://github.com/JuliaLang/julia/issues/23157
[#23187]: https://github.com/JuliaLang/julia/issues/23187
[#23207]: https://github.com/JuliaLang/julia/issues/23207
21 changes: 0 additions & 21 deletions base/dates/io.jl
Original file line number Diff line number Diff line change
Expand Up @@ -557,24 +557,3 @@ function Base.string(dt::Date)
dd = lpad(d, 2, "0")
return "$yy-$mm-$dd"
end

# vectorized
function DateTime(Y::AbstractArray{<:AbstractString}, f::AbstractString; locale::Locale=ENGLISH)
DateTime(Y, DateFormat(f, locale))
end
function DateTime(Y::AbstractArray{<:AbstractString}, df::DateFormat=ISODateTimeFormat)
return reshape(DateTime[parse(DateTime, y, df) for y in Y], size(Y))
end
function Date(Y::AbstractArray{<:AbstractString}, f::AbstractString; locale::Locale=ENGLISH)
Date(Y, DateFormat(f, locale))
end
function Date(Y::AbstractArray{<:AbstractString}, df::DateFormat=ISODateFormat)
return reshape(Date[Date(parse(Date, y, df)) for y in Y], size(Y))
end

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
20 changes: 20 additions & 0 deletions base/deprecated.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1584,6 +1584,26 @@ for op in (:exp, :exp2, :exp10, :log, :log2, :log10,
@eval @deprecate ($op)(x::AbstractSparseVector{<:Number,<:Integer}) ($op).(x)
end

# deprecate remaining vectorized methods from Base.Dates
@eval Dates @deprecate(
DateTime(Y::AbstractArray{<:AbstractString}, f::AbstractString; locale::Locale=ENGLISH),
DateTime.(Y, f; locale=locale) )
@eval Dates @deprecate(
DateTime(Y::AbstractArray{<:AbstractString}, df::DateFormat=ISODateTimeFormat),
DateTime.(Y, df) )
@eval Dates @deprecate(
Date(Y::AbstractArray{<:AbstractString}, f::AbstractString; locale::Locale=ENGLISH),
Date.(Y, f; locale=locale) )
@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
@deprecate is_bsd Sys.isbsd
Expand Down
13 changes: 6 additions & 7 deletions test/dates/io.jl
Original file line number Diff line number Diff line change
Expand Up @@ -319,19 +319,18 @@ f = "ymd"
@test Dates.Date(string(Dates.Date(dt))) == Dates.Date(dt)
@test Dates.DateTime(string(dt)) == dt

# Vectorized
# formerly vectorized Date/DateTime/format methods
dr = ["2000-01-01", "2000-01-02", "2000-01-03", "2000-01-04", "2000-01-05",
"2000-01-06", "2000-01-07", "2000-01-08", "2000-01-09", "2000-01-10"]
dr2 = [Dates.Date(2000) : Dates.Date(2000, 1, 10);]
@test Dates.Date(dr) == dr2
@test Dates.Date(dr, "yyyy-mm-dd") == dr2
@test Dates.Date.(dr) == dr2
@test Dates.Date.(dr, dateformat"yyyy-mm-dd") == dr2
@test Dates.DateTime.(dr) == Dates.DateTime.(dr2)
@test Dates.DateTime(dr, "yyyy-mm-dd") == Dates.DateTime.(dr2)
@test Dates.DateTime.(dr, dateformat"yyyy-mm-dd") == Dates.DateTime.(dr2)

@test Dates.format(dr2) == dr
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could this test have been kept but with a dot, or is there no 1-arg format any more?

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

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

# Issue 13
t = Dates.DateTime(1, 1, 1, 14, 51, 0, 118)
Expand Down