Skip to content

Commit

Permalink
Moved deprecations to deprecated.jl
Browse files Browse the repository at this point in the history
  • Loading branch information
a-hofer committed Sep 15, 2017
1 parent d1e9be1 commit 2824ac7
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 32 deletions.
2 changes: 1 addition & 1 deletion NEWS.md
Expand Up @@ -447,7 +447,7 @@ Deprecated or removed

* `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()`.
alternatives to `now()` ([#23724]).

Command-line option changes
---------------------------
Expand Down
32 changes: 4 additions & 28 deletions base/dates/types.jl
Expand Up @@ -313,34 +313,10 @@ 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'
function DateTime()

if VERSION < v"0.8-"
Base.depwarn("DateTime() is deprecated, use DateTime(1) instead.", :DateTime)
return DateTime(1)
end

return now()
end

function Date()

if VERSION < v"0.8-"
Base.depwarn("Date() is deprecated, use Date(1) instead.", :Date)
return Date(1)
end

return today()
end

function Time()

if VERSION < v"0.8-"
Base.depwarn("Time() is deprecated, use Time(0) instead.", :Time)
return Time(0)
end

return Time(now())
if VERSION >= v"0.8-"
DateTime() = now()
Date() = today()
Time() = Time(now())
end

# Traits, Equality
Expand Down
7 changes: 7 additions & 0 deletions base/deprecated.jl
Expand Up @@ -1806,6 +1806,13 @@ end

@deprecate contains(eq::Function, itr, x) any(y->eq(y,x), itr)

# PR #23724
@eval Dates begin
Base.@deprecate DateTime() DateTime(1)
Base.@deprecate Date() Date(1)
Base.@deprecate Time() Time(0)
end

# END 0.7 deprecations

# BEGIN 1.0 deprecations
Expand Down
6 changes: 3 additions & 3 deletions test/dates/types.jl
Expand Up @@ -61,9 +61,9 @@ t = Dates.Time(Dates.Nanosecond(82800000000000))
# Test empty constructors now equivalence
if VERSION >= v"0.8-"
present = now()
@test DateTime(present) <= DateTime()
@test Date(present) <= Date()
@test Time(present) <= Time()
@test Dates.DateTime(present) <= Dates.DateTime()
@test Dates.Date(present) <= Dates.Date()
@test Dates.Time(present) <= Dates.Time()
end

# Test various input types for Date/DateTime
Expand Down

0 comments on commit 2824ac7

Please sign in to comment.