Skip to content

Commit

Permalink
remove potential future implementation of DateTime(), Date() and Time()
Browse files Browse the repository at this point in the history
  • Loading branch information
fredrikekre authored and a-hofer committed Jan 19, 2018
1 parent 8357a1c commit 3b8c9d3
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 27 deletions.
3 changes: 1 addition & 2 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -971,8 +971,7 @@ Deprecated or removed
* `Base.@gc_preserve` has been deprecated in favor of `GC.@preserve` ([#25616]).

* `DateTime()`, `Date()`, and `Time()` have been deprecated, instead use `DateTime(1)`, `Date(1)`
and `Time(0)` respectively. In a future release `DateTime()`, `Date()`, and `Time()` will be
alternatives to `now()` ([#23724]).
and `Time(0)` respectively ([#23724]).

Command-line option changes
---------------------------
Expand Down
6 changes: 3 additions & 3 deletions stdlib/Dates/docs/src/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Dates.Time

```@docs
Dates.DateTime(::Int64, ::Int64, ::Int64, ::Int64, ::Int64, ::Int64, ::Int64)
Dates.DateTime(::Dates.Period...)
Dates.DateTime(::Dates.Period)
Dates.DateTime(::Function, ::Any...)
Dates.DateTime(::Dates.TimeType)
Dates.DateTime(::AbstractString, ::AbstractString)
Expand All @@ -32,13 +32,13 @@ Dates.DateFormat
Dates.@dateformat_str
Dates.DateTime(::AbstractString, ::Dates.DateFormat)
Dates.Date(::Int64, ::Int64, ::Int64)
Dates.Date(::Dates.Period...)
Dates.Date(::Dates.Period)
Dates.Date(::Function, ::Any, ::Any, ::Any)
Dates.Date(::Dates.TimeType)
Dates.Date(::AbstractString, ::AbstractString)
Dates.Date(::AbstractString, ::Dates.DateFormat)
Dates.Time(::Int64::Int64, ::Int64, ::Int64, ::Int64, ::Int64)
Dates.Time(::Dates.TimePeriod...)
Dates.Time(::Dates.TimePeriod)
Dates.Time(::Function, ::Any...)
Dates.Time(::Dates.DateTime)
Dates.now()
Expand Down
19 changes: 6 additions & 13 deletions stdlib/Dates/src/types.jl
Original file line number Diff line number Diff line change
Expand Up @@ -258,10 +258,10 @@ end
Construct a `DateTime` type by `Period` type parts. Arguments may be in any order. DateTime
parts not provided will default to the value of `Dates.default(period)`.
"""
function DateTime(periods::Period...)
function DateTime(period::Period, periods::Period...)
y = Year(1); m = Month(1); d = Day(1)
h = Hour(0); mi = Minute(0); s = Second(0); ms = Millisecond(0)
for p in periods
for p in (period, periods...)
isa(p, Year) && (y = p::Year)
isa(p, Month) && (m = p::Month)
isa(p, Day) && (d = p::Day)
Expand All @@ -279,9 +279,9 @@ end
Construct a `Date` type by `Period` type parts. Arguments may be in any order. `Date` parts
not provided will default to the value of `Dates.default(period)`.
"""
function Date(periods::Period...)
function Date(period::Period, periods::Period...)
y = Year(1); m = Month(1); d = Day(1)
for p in periods
for p in (period, periods...)
isa(p, Year) && (y = p::Year)
isa(p, Month) && (m = p::Month)
isa(p, Day) && (d = p::Day)
Expand All @@ -295,10 +295,10 @@ end
Construct a `Time` type by `Period` type parts. Arguments may be in any order. `Time` parts
not provided will default to the value of `Dates.default(period)`.
"""
function Time(periods::TimePeriod...)
function Time(period::TimePeriod, periods::TimePeriod...)
h = Hour(0); mi = Minute(0); s = Second(0)
ms = Millisecond(0); us = Microsecond(0); ns = Nanosecond(0)
for p in periods
for p in (period, periods...)
isa(p, Hour) && (h = p::Hour)
isa(p, Minute) && (mi = p::Minute)
isa(p, Second) && (s = p::Second)
Expand All @@ -314,13 +314,6 @@ DateTime(y, m=1, d=1, h=0, mi=0, s=0, ms=0) = DateTime(Int64(y), Int64(m), Int64
Date(y, m=1, d=1) = Date(Int64(y), Int64(m), Int64(d))
Time(h, mi=0, s=0, ms=0, us=0, ns=0) = Time(Int64(h), Int64(mi), Int64(s), Int64(ms), Int64(us), Int64(ns))

# Empty constructors default to 'now'
if VERSION >= v"0.8-"
DateTime() = now()
Date() = today()
Time() = Time(now())
end

# Traits, Equality
Base.isfinite(::Union{Type{T}, T}) where {T<:TimeType} = true
calendar(dt::DateTime) = ISOCalendar
Expand Down
9 changes: 0 additions & 9 deletions stdlib/Dates/test/types.jl
Original file line number Diff line number Diff line change
Expand Up @@ -111,15 +111,6 @@ end
Dates.Microsecond(20), Dates.Nanosecond(25)) == Dates.Time(4, 0, 10, 15, 20, 25)
end

@testset "empty constructors" begin
if VERSION >= v"0.8-"
present = now()
@test Dates.DateTime(present) <= Dates.DateTime()
@test Dates.Date(present) <= Dates.Date()
@test Dates.Time(present) <= Dates.Time()
end
end

@testset "various input types for Date/DateTime" begin
test = Dates.Date(1, 1, 1)
@test Dates.Date(Int8(1), Int8(1), Int8(1)) == test
Expand Down

0 comments on commit 3b8c9d3

Please sign in to comment.