From 312a035c3b6430e90b86456296248221a2bd17ff Mon Sep 17 00:00:00 2001 From: Kristoffer Carlsson Date: Fri, 3 Nov 2017 17:16:16 +0100 Subject: [PATCH] wip move Dates to stdlib --- base/deprecated.jl | 124 +---------- base/exports.jl | 1 - base/number.jl | 4 +- base/sysimg.jl | 5 +- doc/make.jl | 6 +- doc/src/stdlib/dates.md | 194 ------------------ stdlib/Dates/docs/src/index.md | 194 ++++++++++++++++++ {base/dates => stdlib/Dates/src}/Dates.jl | 1 + {base/dates => stdlib/Dates/src}/accessors.jl | 0 {base/dates => stdlib/Dates/src}/adjusters.jl | 39 ++-- .../dates => stdlib/Dates/src}/arithmetic.jl | 0 .../dates => stdlib/Dates/src}/conversions.jl | 0 stdlib/Dates/src/deprecated.jl | 41 ++++ {base/dates => stdlib/Dates/src}/io.jl | 0 {base/dates => stdlib/Dates/src}/parse.jl | 0 {base/dates => stdlib/Dates/src}/periods.jl | 0 {base/dates => stdlib/Dates/src}/query.jl | 0 {base/dates => stdlib/Dates/src}/ranges.jl | 0 {base/dates => stdlib/Dates/src}/rounding.jl | 0 {base/dates => stdlib/Dates/src}/types.jl | 0 .../dates => stdlib/Dates/test}/accessors.jl | 0 .../dates => stdlib/Dates/test}/adjusters.jl | 0 .../dates => stdlib/Dates/test}/arithmetic.jl | 0 .../Dates/test}/conversions.jl | 0 {test/dates => stdlib/Dates/test}/io.jl | 0 {test/dates => stdlib/Dates/test}/periods.jl | 0 {test/dates => stdlib/Dates/test}/query.jl | 0 {test/dates => stdlib/Dates/test}/ranges.jl | 6 + {test/dates => stdlib/Dates/test}/rounding.jl | 0 stdlib/Dates/test/runtests.jl | 26 +++ {test/dates => stdlib/Dates/test}/types.jl | 0 test/channels.jl | 2 +- test/choosetests.jl | 13 +- test/core.jl | 5 - test/nullable.jl | 2 - test/ranges.jl | 5 - test/threads.jl | 3 +- 37 files changed, 297 insertions(+), 374 deletions(-) delete mode 100644 doc/src/stdlib/dates.md create mode 100644 stdlib/Dates/docs/src/index.md rename {base/dates => stdlib/Dates/src}/Dates.jl (99%) rename {base/dates => stdlib/Dates/src}/accessors.jl (100%) rename {base/dates => stdlib/Dates/src}/adjusters.jl (89%) rename {base/dates => stdlib/Dates/src}/arithmetic.jl (100%) rename {base/dates => stdlib/Dates/src}/conversions.jl (100%) create mode 100644 stdlib/Dates/src/deprecated.jl rename {base/dates => stdlib/Dates/src}/io.jl (100%) rename {base/dates => stdlib/Dates/src}/parse.jl (100%) rename {base/dates => stdlib/Dates/src}/periods.jl (100%) rename {base/dates => stdlib/Dates/src}/query.jl (100%) rename {base/dates => stdlib/Dates/src}/ranges.jl (100%) rename {base/dates => stdlib/Dates/src}/rounding.jl (100%) rename {base/dates => stdlib/Dates/src}/types.jl (100%) rename {test/dates => stdlib/Dates/test}/accessors.jl (100%) rename {test/dates => stdlib/Dates/test}/adjusters.jl (100%) rename {test/dates => stdlib/Dates/test}/arithmetic.jl (100%) rename {test/dates => stdlib/Dates/test}/conversions.jl (100%) rename {test/dates => stdlib/Dates/test}/io.jl (100%) rename {test/dates => stdlib/Dates/test}/periods.jl (100%) rename {test/dates => stdlib/Dates/test}/query.jl (100%) rename {test/dates => stdlib/Dates/test}/ranges.jl (98%) rename {test/dates => stdlib/Dates/test}/rounding.jl (100%) create mode 100644 stdlib/Dates/test/runtests.jl rename {test/dates => stdlib/Dates/test}/types.jl (100%) diff --git a/base/deprecated.jl b/base/deprecated.jl index ee81e772f9360a..daa8fea2d31830 100644 --- a/base/deprecated.jl +++ b/base/deprecated.jl @@ -277,31 +277,6 @@ end # base/complex.jl @dep_vectorize_1arg Complex round @dep_vectorize_1arg Complex float -# base/dates/*.jl -for f in (:unix2datetime, :rata2datetime, :julian2datetime) # base/dates/conversions.jl - @eval Dates Base.@dep_vectorize_1arg Real $f -end -for f in ( - # base/dates/accessors.jl - :year, :month, :day, :week, :dayofmonth, :yearmonth, :monthday, :yearmonthday, - # base/dates/adjusters.jl - :firstdayofweek, :lastdayofweek, :firstdayofmonth, - :lastdayofmonth, :firstdayofyear, :lastdayofyear, - :firstdayofquarter, :lastdayofquarter, - # base/dates/query.jl - :dayname, :dayabbr, :dayofweek, :dayofweekofmonth, - :daysofweekinmonth, :monthname, :monthabbr, :daysinmonth, - :isleapyear, :dayofyear, :daysinyear, :quarterofyear, :dayofquarter, - ) - @eval Dates Base.@dep_vectorize_1arg Dates.TimeType $f -end -for f in ( - :hour, :minute, :second, :millisecond, # base/dates/accessors.jl - :Date, :datetime2unix, :datetime2rata, :datetime2julian, # base/dates/conversions.jl - ) - @eval Dates Base.@dep_vectorize_1arg Dates.DateTime $f -end -@eval Dates Base.@dep_vectorize_1arg Dates.Date Datetime # base/dates/conversions.jl # Deprecate @vectorize_2arg-vectorized functions from... for f in ( @@ -477,19 +452,6 @@ end @deprecate takebuf_array take! @deprecate takebuf_string(b) String(take!(b)) -# #19288 -@eval Base.Dates begin - function recur(fun::Function, dr::StepRange{<:TimeType}; negate::Bool=false, limit::Int=10000) - Base.depwarn("Dates.recur is deprecated, use filter instead.",:recur) - if negate - filter(x -> !fun(x), dr) - else - filter(fun, dr) - end - end - recur(fun::Function, start::T, stop::T; step::Period=Day(1), negate::Bool=false, limit::Int=10000) where {T<:TimeType} = recur(fun, start:step:stop; negate=negate) -end - # Index conversions revamp; #19730 function getindex(A::LogicalIndex, i::Int) depwarn("getindex(A::LogicalIndex, i) is deprecated; use iteration or index into the result of `collect(A)` instead.", :getindex) @@ -790,12 +752,6 @@ import .Math: clamp @deprecate rem(A::Number, B::AbstractArray) rem.(A, B) @deprecate rem(A::AbstractArray, B::Number) rem.(A, B) -# Deprecate manually vectorized div, mod, and % methods for dates -@deprecate div(X::StridedArray{P}, y::P) where {P<:Dates.Period} div.(X, y) -@deprecate div(X::StridedArray{<:Dates.Period}, y::Integer) div.(X, y) -@deprecate (%)(X::StridedArray{P}, y::P) where {P<:Dates.Period} X .% y -@deprecate mod(X::StridedArray{P}, y::P) where {P<:Dates.Period} mod.(X, y) - # Deprecate manually vectorized mod methods in favor of compact broadcast syntax @deprecate mod(B::BitArray, x::Bool) mod.(B, x) @deprecate mod(x::Bool, B::BitArray) mod.(x, B) @@ -993,19 +949,6 @@ end @deprecate EachLine(stream, ondone) EachLine(stream, ondone=ondone) -# These conversions should not be defined, see #19896 -@deprecate convert(::Type{T}, x::Dates.Period) where {T<:Number} convert(T, Dates.value(x)) -@deprecate convert(::Type{T}, x::Real) where {T<:Dates.Period} T(x) -@deprecate convert(::Type{R}, x::Dates.DateTime) where {R<:Real} R(Dates.value(x)) -@deprecate convert(::Type{R}, x::Dates.Date) where {R<:Real} R(Dates.value(x)) -@deprecate convert(::Type{Dates.DateTime}, x::Real) Dates.DateTime(Dates.Millisecond(x)) -@deprecate convert(::Type{Dates.Date}, x::Real) Dates.Date(Dates.Day(x)) - -function colon(start::T, stop::T) where T<:Dates.Period - depwarn("$start:$stop is deprecated, use $start:$T(1):$stop instead.", :colon) - colon(start, T(1), stop) -end - # LibGit2 refactor (#19839) @eval Base.LibGit2 begin Base.@deprecate_binding Oid GitHash @@ -1030,20 +973,6 @@ end Base.cat(repo::GitRepo, spec::Union{AbstractString,AbstractGitHash}) = cat(repo, GitBlob, spec) end -# when this deprecation is deleted, remove all calls to it, and all -# negate=nothing keyword arguments, from base/dates/adjusters.jl -@eval Dates function deprecate_negate(f, func, sig, negate) - if negate === nothing - return func - else - msg = "$f($sig; negate=$negate) is deprecated, use $f(" - negate && (msg *= "!") - msg *= "$sig) instead." - Base.depwarn(msg, f) - return negate ? !func : func - end -end - # TODO: remove `:typealias` from BINDING_HEADS in base/docs/Docs.jl # TODO: remove `'typealias` case in expand-table in julia-syntax.scm @@ -1169,17 +1098,6 @@ end @deprecate_binding LinearSlow IndexCartesian false @deprecate_binding linearindexing IndexStyle false -# #20876 -@eval Base.Dates begin - function Base.Dates.parse(x::AbstractString, df::DateFormat) - Base.depwarn(string( - "`Dates.parse(x::AbstractString, df::DateFormat)` is deprecated, use ", - "`sort!(filter!(el -> isa(el, Dates.Period), Dates.parse_components(x, df), rev=true, lt=Dates.periodisless)` ", - " instead."), :parse) - sort!(filter!(el -> isa(el, Period), parse_components(x, df)), rev=true, lt=periodisless) - end -end - # #19635 for fname in (:ones, :zeros) @eval @deprecate ($fname)(T::Type, arr) ($fname)(T, size(arr)) @@ -1354,6 +1272,12 @@ export conv, conv2, deconv, filt, filt!, xcorr @deprecate_moved watch_file "FileWatching" true true @deprecate_moved FileMonitor "FileWatching" true true +@deprecate_binding Dates nothing true ", run `using Dates` instead" +@deprecate_moved DateTime "Dates" true true +@deprecate_moved DateFormat "Dates" true true +@eval @deprecate_moved $(Symbol("@dateformat_str")) "Dates" true true +@deprecate_moved now "Dates" true true + # PR #21709 @deprecate cov(x::AbstractVector, corrected::Bool) cov(x, corrected=corrected) @deprecate cov(x::AbstractMatrix, vardim::Int, corrected::Bool) cov(x, vardim, corrected=corrected) @@ -1480,26 +1404,6 @@ 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 @@ -1715,11 +1619,6 @@ import .Iterators.enumerate @deprecate -(a::Number, b::AbstractArray) broadcast(-, a, b) @deprecate -(a::AbstractArray, b::Number) broadcast(-, a, b) -@deprecate +(a::Dates.GeneralPeriod, b::StridedArray{<:Dates.GeneralPeriod}) broadcast(+, a, b) -@deprecate +(a::StridedArray{<:Dates.GeneralPeriod}, b::Dates.GeneralPeriod) broadcast(+, a, b) -@deprecate -(a::Dates.GeneralPeriod, b::StridedArray{<:Dates.GeneralPeriod}) broadcast(-, a, b) -@deprecate -(a::StridedArray{<:Dates.GeneralPeriod}, b::Dates.GeneralPeriod) broadcast(-, a, b) - # PR #23640 # when this deprecation is deleted, remove all calls to it, and replace all keywords of: # `payload::Union{CredentialPayload,Nullable{<:AbstractCredentials}}` with @@ -2073,17 +1972,6 @@ end # issue #24167 @deprecate EnvHash EnvDict -# #24258 -# Physical units define an equivalence class: there is no such thing as a step of "1" (is -# it one day or one second or one nanosecond?). So require the user to specify the step -# (in physical units). -@deprecate colon(start::T, stop::T) where {T<:DateTime} start:Dates.Day(1):stop -@deprecate colon(start::T, stop::T) where {T<:Date} start:Dates.Day(1):stop -@deprecate colon(start::T, stop::T) where {T<:Dates.Time} start:Dates.Second(1):stop - -@deprecate range(start::DateTime, len::Integer) range(start, Dates.Day(1), len) -@deprecate range(start::Date, len::Integer) range(start, Dates.Day(1), len) - # END 0.7 deprecations # BEGIN 1.0 deprecations diff --git a/base/exports.jl b/base/exports.jl index 0e30396010261f..0aef0072131711 100644 --- a/base/exports.jl +++ b/base/exports.jl @@ -6,7 +6,6 @@ export Pkg, LibGit2, StackTraces, - Dates, Sys, Libc, Libdl, diff --git a/base/number.jl b/base/number.jl index b3336751a3f63d..18bee75b761cd0 100644 --- a/base/number.jl +++ b/base/number.jl @@ -263,7 +263,7 @@ julia> one(3.7) julia> one(Int) 1 -julia> one(Dates.Day(1)) +julia> import Dates; one(Dates.Day(1)) 1 ``` """ @@ -285,7 +285,7 @@ while `oneunit` is dimensionful (of the same type as `x`, or of type `T`). julia> oneunit(3.7) 1.0 -julia> oneunit(Dates.Day) +julia> import Dates; oneunit(Dates.Day) 1 day ``` """ diff --git a/base/sysimg.jl b/base/sysimg.jl index 0a3963d4872a26..0892a35b4a001d 100644 --- a/base/sysimg.jl +++ b/base/sysimg.jl @@ -400,10 +400,6 @@ include("libgit2/libgit2.jl") # package manager include("pkg/pkg.jl") -# dates -include("dates/Dates.jl") -import .Dates: Date, DateTime, DateFormat, @dateformat_str, now - # sparse matrices, vectors, and sparse linear algebra include("sparse/sparse.jl") using .SparseArrays @@ -473,6 +469,7 @@ unshift!(Base._included_files, (@__MODULE__, joinpath(@__DIR__, "sysimg.jl"))) # load some stdlib packages but don't put their names in Main Base.require(:DelimitedFiles) Base.require(:Test) +Base.require(:Dates) empty!(LOAD_PATH) diff --git a/doc/make.jl b/doc/make.jl index 7bff07d8962e79..b9355da973e31e 100644 --- a/doc/make.jl +++ b/doc/make.jl @@ -28,6 +28,7 @@ if Sys.iswindows() cp_q("../stdlib/Profile/docs/src/index.md", "src/stdlib/profile.md") cp_q("../stdlib/Base64/docs/src/index.md", "src/stdlib/base64.md") cp_q("../stdlib/FileWatching/docs/src/index.md", "src/stdlib/filewatching.md") + cp_q("../stdlib/Dates/docs/src/index.md", "src/stdlib/dates.md") else symlink_q("../../../stdlib/DelimitedFiles/docs/src/index.md", "src/stdlib/delimitedfiles.md") symlink_q("../../../stdlib/Test/docs/src/index.md", "src/stdlib/test.md") @@ -36,6 +37,7 @@ else symlink_q("../../../stdlib/Profile/docs/src/index.md", "src/stdlib/profile.md") symlink_q("../../../stdlib/Base64/docs/src/index.md", "src/stdlib/base64.md") symlink_q("../../../stdlib/FileWatching/docs/src/index.md", "src/stdlib/filewatching.md") + symlink_q("../../../stdlib/Dates/docs/src/index.md", "src/stdlib/dates.md") end const PAGES = [ @@ -143,11 +145,11 @@ const PAGES = [ ], ] -using DelimitedFiles, Test, Mmap, SharedArrays, Profile, Base64, FileWatching +using DelimitedFiles, Test, Mmap, SharedArrays, Profile, Base64, FileWatching, Dates makedocs( build = joinpath(pwd(), "_build/html/en"), - modules = [Base, Core, BuildSysImg, DelimitedFiles, Test, Mmap, SharedArrays, Profile, Base64, FileWatching], + modules = [Base, Core, BuildSysImg, DelimitedFiles, Test, Mmap, SharedArrays, Profile, Base64, FileWatching, Dates], clean = false, doctest = "doctest" in ARGS, linkcheck = "linkcheck" in ARGS, diff --git a/doc/src/stdlib/dates.md b/doc/src/stdlib/dates.md deleted file mode 100644 index b7ff1f950bda0d..00000000000000 --- a/doc/src/stdlib/dates.md +++ /dev/null @@ -1,194 +0,0 @@ -# [Dates and Time](@id stdlib-dates) - -## Dates and Time Types - -```@docs -Base.Dates.Period -Base.Dates.CompoundPeriod -Base.Dates.Instant -Base.Dates.UTInstant -Base.Dates.TimeType -Base.Dates.DateTime -Base.Dates.Date -Base.Dates.Time -``` - -## Dates Functions - -All Dates functions are defined in the `Dates` module; note that only the `Date`, `DateTime`, -and `now` functions are exported; to use all other `Dates` functions, you'll need to prefix each -function call with an explicit `Dates.`, e.g. `Dates.dayofweek(dt)`. Alternatively, you can write -`using Base.Dates` to bring all exported functions into `Main` to be used without the `Dates.` -prefix. - -```@docs -Base.Dates.DateTime(::Int64, ::Int64, ::Int64, ::Int64, ::Int64, ::Int64, ::Int64) -Base.Dates.DateTime(::Base.Dates.Period...) -Base.Dates.DateTime(::Function, ::Any...) -Base.Dates.DateTime(::Base.Dates.TimeType) -Base.Dates.DateTime(::AbstractString, ::AbstractString) -Base.Dates.format -Base.Dates.DateFormat -Base.Dates.@dateformat_str -Base.Dates.DateTime(::AbstractString, ::Base.Dates.DateFormat) -Base.Dates.Date(::Int64, ::Int64, ::Int64) -Base.Dates.Date(::Base.Dates.Period...) -Base.Dates.Date(::Function, ::Any, ::Any, ::Any) -Base.Dates.Date(::Base.Dates.TimeType) -Base.Dates.Date(::AbstractString, ::AbstractString) -Base.Dates.Date(::AbstractString, ::Base.Dates.DateFormat) -Base.Dates.Time(::Int64::Int64, ::Int64, ::Int64, ::Int64, ::Int64) -Base.Dates.Time(::Base.Dates.TimePeriod...) -Base.Dates.Time(::Function, ::Any...) -Base.Dates.Time(::Base.Dates.DateTime) -Base.Dates.now() -Base.Dates.now(::Type{Base.Dates.UTC}) -Base.eps -``` - -### Accessor Functions - -```@docs -Base.Dates.year -Base.Dates.month -Base.Dates.week -Base.Dates.day -Base.Dates.hour -Base.Dates.minute -Base.Dates.second -Base.Dates.millisecond -Base.Dates.microsecond -Base.Dates.nanosecond -Base.Dates.Year(::Base.Dates.TimeType) -Base.Dates.Month(::Base.Dates.TimeType) -Base.Dates.Week(::Base.Dates.TimeType) -Base.Dates.Day(::Base.Dates.TimeType) -Base.Dates.Hour(::DateTime) -Base.Dates.Minute(::DateTime) -Base.Dates.Second(::DateTime) -Base.Dates.Millisecond(::DateTime) -Base.Dates.Microsecond(::Dates.Time) -Base.Dates.Nanosecond(::Dates.Time) -Base.Dates.yearmonth -Base.Dates.monthday -Base.Dates.yearmonthday -``` - -### Query Functions - -```@docs -Base.Dates.dayname -Base.Dates.dayabbr -Base.Dates.dayofweek -Base.Dates.dayofmonth -Base.Dates.dayofweekofmonth -Base.Dates.daysofweekinmonth -Base.Dates.monthname -Base.Dates.monthabbr -Base.Dates.daysinmonth -Base.Dates.isleapyear -Base.Dates.dayofyear -Base.Dates.daysinyear -Base.Dates.quarterofyear -Base.Dates.dayofquarter -``` - -### Adjuster Functions - -```@docs -Base.trunc(::Base.Dates.TimeType, ::Type{Base.Dates.Period}) -Base.Dates.firstdayofweek -Base.Dates.lastdayofweek -Base.Dates.firstdayofmonth -Base.Dates.lastdayofmonth -Base.Dates.firstdayofyear -Base.Dates.lastdayofyear -Base.Dates.firstdayofquarter -Base.Dates.lastdayofquarter -Base.Dates.tonext(::Base.Dates.TimeType, ::Int) -Base.Dates.toprev(::Base.Dates.TimeType, ::Int) -Base.Dates.tofirst -Base.Dates.tolast -Base.Dates.tonext(::Function, ::Base.Dates.TimeType) -Base.Dates.toprev(::Function, ::Base.Dates.TimeType) -``` - -### Periods - -```@docs -Base.Dates.Period(::Any) -Base.Dates.CompoundPeriod(::Vector{<:Base.Dates.Period}) -Base.Dates.default -``` - -### Rounding Functions - -`Date` and `DateTime` values can be rounded to a specified resolution (e.g., 1 month or 15 minutes) -with `floor`, `ceil`, or `round`. - -```@docs -Base.floor(::Base.Dates.TimeType, ::Base.Dates.Period) -Base.ceil(::Base.Dates.TimeType, ::Base.Dates.Period) -Base.round(::Base.Dates.TimeType, ::Base.Dates.Period, ::RoundingMode{:NearestTiesUp}) -``` - -Most `Period` values can also be rounded to a specified resolution: - -```@docs -Base.floor(::Base.Dates.ConvertiblePeriod, ::T) where T <: Base.Dates.ConvertiblePeriod -Base.ceil(::Base.Dates.ConvertiblePeriod, ::Base.Dates.ConvertiblePeriod) -Base.round(::Base.Dates.ConvertiblePeriod, ::Base.Dates.ConvertiblePeriod, ::RoundingMode{:NearestTiesUp}) -``` - -The following functions are not exported: - -```@docs -Base.Dates.floorceil -Base.Dates.epochdays2date -Base.Dates.epochms2datetime -Base.Dates.date2epochdays -Base.Dates.datetime2epochms -``` - -### Conversion Functions - -```@docs -Base.Dates.today -Base.Dates.unix2datetime -Base.Dates.datetime2unix -Base.Dates.julian2datetime -Base.Dates.datetime2julian -Base.Dates.rata2datetime -Base.Dates.datetime2rata -``` - -### Constants - -Days of the Week: - -| Variable | Abbr. | Value (Int) | -|:----------- |:----- |:----------- | -| `Monday` | `Mon` | 1 | -| `Tuesday` | `Tue` | 2 | -| `Wednesday` | `Wed` | 3 | -| `Thursday` | `Thu` | 4 | -| `Friday` | `Fri` | 5 | -| `Saturday` | `Sat` | 6 | -| `Sunday` | `Sun` | 7 | - -Months of the Year: - -| Variable | Abbr. | Value (Int) | -|:----------- |:----- |:----------- | -| `January` | `Jan` | 1 | -| `February` | `Feb` | 2 | -| `March` | `Mar` | 3 | -| `April` | `Apr` | 4 | -| `May` | `May` | 5 | -| `June` | `Jun` | 6 | -| `July` | `Jul` | 7 | -| `August` | `Aug` | 8 | -| `September` | `Sep` | 9 | -| `October` | `Oct` | 10 | -| `November` | `Nov` | 11 | -| `December` | `Dec` | 12 | diff --git a/stdlib/Dates/docs/src/index.md b/stdlib/Dates/docs/src/index.md new file mode 100644 index 00000000000000..d3e79a8c316b03 --- /dev/null +++ b/stdlib/Dates/docs/src/index.md @@ -0,0 +1,194 @@ +# [Dates and Time](@id stdlib-dates) + +## Dates and Time Types + +```@docs +Dates.Period +Dates.CompoundPeriod +Dates.Instant +Dates.UTInstant +Dates.TimeType +Dates.DateTime +Dates.Date +Dates.Time +``` + +## Dates Functions + +All Dates functions are defined in the `Dates` module; note that only the `Date`, `DateTime`, +and `now` functions are exported; to use all other `Dates` functions, you'll need to prefix each +function call with an explicit `Dates.`, e.g. `Dates.dayofweek(dt)`. Alternatively, you can write +`using Base.Dates` to bring all exported functions into `Main` to be used without the `Dates.` +prefix. + +```@docs +Dates.DateTime(::Int64, ::Int64, ::Int64, ::Int64, ::Int64, ::Int64, ::Int64) +Dates.DateTime(::Dates.Period...) +Dates.DateTime(::Function, ::Any...) +Dates.DateTime(::Dates.TimeType) +Dates.DateTime(::AbstractString, ::AbstractString) +Dates.format +Dates.DateFormat +Dates.@dateformat_str +Dates.DateTime(::AbstractString, ::Dates.DateFormat) +Dates.Date(::Int64, ::Int64, ::Int64) +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(::Function, ::Any...) +Dates.Time(::Dates.DateTime) +Dates.now() +Dates.now(::Type{Dates.UTC}) +Base.eps +``` + +### Accessor Functions + +```@docs +Dates.year +Dates.month +Dates.week +Dates.day +Dates.hour +Dates.minute +Dates.second +Dates.millisecond +Dates.microsecond +Dates.nanosecond +Dates.Year(::Dates.TimeType) +Dates.Month(::Dates.TimeType) +Dates.Week(::Dates.TimeType) +Dates.Day(::Dates.TimeType) +Dates.Hour(::DateTime) +Dates.Minute(::DateTime) +Dates.Second(::DateTime) +Dates.Millisecond(::DateTime) +Dates.Microsecond(::Dates.Time) +Dates.Nanosecond(::Dates.Time) +Dates.yearmonth +Dates.monthday +Dates.yearmonthday +``` + +### Query Functions + +```@docs +Dates.dayname +Dates.dayabbr +Dates.dayofweek +Dates.dayofmonth +Dates.dayofweekofmonth +Dates.daysofweekinmonth +Dates.monthname +Dates.monthabbr +Dates.daysinmonth +Dates.isleapyear +Dates.dayofyear +Dates.daysinyear +Dates.quarterofyear +Dates.dayofquarter +``` + +### Adjuster Functions + +```@docs +Base.trunc(::Dates.TimeType, ::Type{Dates.Period}) +Dates.firstdayofweek +Dates.lastdayofweek +Dates.firstdayofmonth +Dates.lastdayofmonth +Dates.firstdayofyear +Dates.lastdayofyear +Dates.firstdayofquarter +Dates.lastdayofquarter +Dates.tonext(::Dates.TimeType, ::Int) +Dates.toprev(::Dates.TimeType, ::Int) +Dates.tofirst +Dates.tolast +Dates.tonext(::Function, ::Dates.TimeType) +Dates.toprev(::Function, ::Dates.TimeType) +``` + +### Periods + +```@docs +Dates.Period(::Any) +Dates.CompoundPeriod(::Vector{<:Dates.Period}) +Dates.default +``` + +### Rounding Functions + +`Date` and `DateTime` values can be rounded to a specified resolution (e.g., 1 month or 15 minutes) +with `floor`, `ceil`, or `round`. + +```@docs +Base.floor(::Dates.TimeType, ::Dates.Period) +Base.ceil(::Dates.TimeType, ::Dates.Period) +Base.round(::Dates.TimeType, ::Dates.Period, ::RoundingMode{:NearestTiesUp}) +``` + +Most `Period` values can also be rounded to a specified resolution: + +```@docs +Base.floor(::Dates.ConvertiblePeriod, ::T) where T <: Dates.ConvertiblePeriod +Base.ceil(::Dates.ConvertiblePeriod, ::Dates.ConvertiblePeriod) +Base.round(::Dates.ConvertiblePeriod, ::Dates.ConvertiblePeriod, ::RoundingMode{:NearestTiesUp}) +``` + +The following functions are not exported: + +```@docs +Dates.floorceil +Dates.epochdays2date +Dates.epochms2datetime +Dates.date2epochdays +Dates.datetime2epochms +``` + +### Conversion Functions + +```@docs +Dates.today +Dates.unix2datetime +Dates.datetime2unix +Dates.julian2datetime +Dates.datetime2julian +Dates.rata2datetime +Dates.datetime2rata +``` + +### Constants + +Days of the Week: + +| Variable | Abbr. | Value (Int) | +|:----------- |:----- |:----------- | +| `Monday` | `Mon` | 1 | +| `Tuesday` | `Tue` | 2 | +| `Wednesday` | `Wed` | 3 | +| `Thursday` | `Thu` | 4 | +| `Friday` | `Fri` | 5 | +| `Saturday` | `Sat` | 6 | +| `Sunday` | `Sun` | 7 | + +Months of the Year: + +| Variable | Abbr. | Value (Int) | +|:----------- |:----- |:----------- | +| `January` | `Jan` | 1 | +| `February` | `Feb` | 2 | +| `March` | `Mar` | 3 | +| `April` | `Apr` | 4 | +| `May` | `May` | 5 | +| `June` | `Jun` | 6 | +| `July` | `Jul` | 7 | +| `August` | `Aug` | 8 | +| `September` | `Sep` | 9 | +| `October` | `Oct` | 10 | +| `November` | `Nov` | 11 | +| `December` | `Dec` | 12 | diff --git a/base/dates/Dates.jl b/stdlib/Dates/src/Dates.jl similarity index 99% rename from base/dates/Dates.jl rename to stdlib/Dates/src/Dates.jl index 44ed2aefa79721..6001e4d60d28bd 100644 --- a/base/dates/Dates.jl +++ b/stdlib/Dates/src/Dates.jl @@ -48,6 +48,7 @@ include("adjusters.jl") include("rounding.jl") include("io.jl") include("parse.jl") +include("deprecated.jl") export Period, DatePeriod, TimePeriod, Year, Month, Week, Day, Hour, Minute, Second, Millisecond, diff --git a/base/dates/accessors.jl b/stdlib/Dates/src/accessors.jl similarity index 100% rename from base/dates/accessors.jl rename to stdlib/Dates/src/accessors.jl diff --git a/base/dates/adjusters.jl b/stdlib/Dates/src/adjusters.jl similarity index 89% rename from base/dates/adjusters.jl rename to stdlib/Dates/src/adjusters.jl index 44c66ac6959940..4687b22badad54 100644 --- a/base/dates/adjusters.jl +++ b/stdlib/Dates/src/adjusters.jl @@ -202,8 +202,7 @@ function adjust(df::DateFunction, start, step, limit) throw(ArgumentError("Adjustment limit reached: $limit iterations")) end -function adjust(func::Function, start; step::Period=Day(1), negate=nothing, limit::Int=10000) - func = deprecate_negate(:adjust, func, "func,start", negate) +function adjust(func::Function, start; step::Period=Day(1), limit::Int=10000) return adjust(DateFunction(func, start), start, step, limit) end @@ -232,8 +231,7 @@ Stacktrace: [...] ``` """ -function Date(func::Function, y, m=1, d=1; step::Period=Day(1), negate=nothing, limit::Int=10000) - func = deprecate_negate(:Date, func, "func,y,m,d", negate) +function Date(func::Function, y, m=1, d=1; step::Period=Day(1), limit::Int=10000) return adjust(DateFunction(func, Date(y, m, d)), Date(y, m, d), step, limit) end @@ -259,24 +257,19 @@ Stacktrace: """ DateTime(::Function, args...) -function DateTime(func::Function, y, m=1; step::Period=Day(1), negate=nothing, limit::Int=10000) - func = deprecate_negate(:DateTime, func, "func,y,m", negate) +function DateTime(func::Function, y, m=1; step::Period=Day(1), limit::Int=10000) return adjust(DateFunction(func, DateTime(y, m)), DateTime(y, m), step, limit) end -function DateTime(func::Function, y, m, d; step::Period=Hour(1), negate=nothing, limit::Int=10000) - func = deprecate_negate(:DateTime, func, "func,y,m,d", negate) +function DateTime(func::Function, y, m, d; step::Period=Hour(1), limit::Int=10000) return adjust(DateFunction(func, DateTime(y)), DateTime(y, m, d), step, limit) end -function DateTime(func::Function, y, m, d, h; step::Period=Minute(1), negate=nothing, limit::Int=10000) - func = deprecate_negate(:DateTime, func, "func,y,m,d,h", negate) +function DateTime(func::Function, y, m, d, h; step::Period=Minute(1), limit::Int=10000) return adjust(DateFunction(func, DateTime(y)), DateTime(y, m, d, h), step, limit) end -function DateTime(func::Function, y, m, d, h, mi; step::Period=Second(1), negate=nothing, limit::Int=10000) - func = deprecate_negate(:DateTime, func, "func,y,m,d,h,mi", negate) +function DateTime(func::Function, y, m, d, h, mi; step::Period=Second(1), limit::Int=10000) return adjust(DateFunction(func, DateTime(y)), DateTime(y, m, d, h, mi), step, limit) end -function DateTime(func::Function, y, m, d, h, mi, s; step::Period=Millisecond(1), negate=nothing, limit::Int=10000) - func = deprecate_negate(:DateTime, func, "func,y,m,d,h,mi,s", negate) +function DateTime(func::Function, y, m, d, h, mi, s; step::Period=Millisecond(1), limit::Int=10000) return adjust(DateFunction(func, DateTime(y)), DateTime(y, m, d, h, mi, s), step, limit) end @@ -310,20 +303,16 @@ Stacktrace: """ Time(::Function, args...) -function Time(func::Function, h, mi=0; step::Period=Second(1), negate=nothing, limit::Int=10000) - func = deprecate_negate(:Time, func, "func,h,mi", negate) +function Time(func::Function, h, mi=0; step::Period=Second(1), limit::Int=10000) return adjust(DateFunction(func, Time(h, mi)), Time(h, mi), step, limit) end -function Time(func::Function, h, mi, s; step::Period=Millisecond(1), negate=nothing, limit::Int=10000) - func = deprecate_negate(:Time, func, "func,h,mi,s", negate) +function Time(func::Function, h, mi, s; step::Period=Millisecond(1), limit::Int=10000) return adjust(DateFunction(func, Time(h, mi, s)), Time(h, mi, s), step, limit) end -function Time(func::Function, h, mi, s, ms; step::Period=Microsecond(1), negate=nothing, limit::Int=10000) - func = deprecate_negate(:Time, func, "func,h,mi,s,ms", negate) +function Time(func::Function, h, mi, s, ms; step::Period=Microsecond(1), limit::Int=10000) return adjust(DateFunction(func, Time(h, mi, s, ms)), Time(h, mi, s, ms), step, limit) end -function Time(func::Function, h, mi, s, ms, us; step::Period=Nanosecond(1), negate=nothing, limit::Int=10000) - func = deprecate_negate(:Time, func, "func,h,mi,s,ms,us", negate) +function Time(func::Function, h, mi, s, ms, us; step::Period=Nanosecond(1), limit::Int=10000) return adjust(DateFunction(func, Time(h, mi, s, ms, us)), Time(h, mi, s, ms, us), step, limit) end @@ -354,8 +343,7 @@ Adjusts `dt` by iterating at most `limit` iterations by `step` increments until returns `true`. `func` must take a single `TimeType` argument and return a [`Bool`](@ref). `same` allows `dt` to be considered in satisfying `func`. """ -function tonext(func::Function, dt::TimeType; step::Period=Day(1), negate=nothing, limit::Int=10000, same::Bool=false) - func = deprecate_negate(:tonext, func, "func,dt", negate) +function tonext(func::Function, dt::TimeType; step::Period=Day(1), limit::Int=10000, same::Bool=false) return adjust(DateFunction(func, dt), same ? dt : dt + step, step, limit) end @@ -375,8 +363,7 @@ Adjusts `dt` by iterating at most `limit` iterations by `step` increments until returns `true`. `func` must take a single `TimeType` argument and return a [`Bool`](@ref). `same` allows `dt` to be considered in satisfying `func`. """ -function toprev(func::Function, dt::TimeType; step::Period=Day(-1), negate=nothing, limit::Int=10000, same::Bool=false) - func = deprecate_negate(:toprev, func, "func,dt", negate) +function toprev(func::Function, dt::TimeType; step::Period=Day(-1), limit::Int=10000, same::Bool=false) return adjust(DateFunction(func, dt), same ? dt : dt + step, step, limit) end diff --git a/base/dates/arithmetic.jl b/stdlib/Dates/src/arithmetic.jl similarity index 100% rename from base/dates/arithmetic.jl rename to stdlib/Dates/src/arithmetic.jl diff --git a/base/dates/conversions.jl b/stdlib/Dates/src/conversions.jl similarity index 100% rename from base/dates/conversions.jl rename to stdlib/Dates/src/conversions.jl diff --git a/stdlib/Dates/src/deprecated.jl b/stdlib/Dates/src/deprecated.jl new file mode 100644 index 00000000000000..89a1cca11d2c69 --- /dev/null +++ b/stdlib/Dates/src/deprecated.jl @@ -0,0 +1,41 @@ +# 0.7 deprecations + +import Base.colon +import Base.range + +# deprecate remaining vectorized methods from Base.Dates +@deprecate( + DateTime(Y::AbstractArray{<:AbstractString}, f::AbstractString; locale::Locale=ENGLISH), + DateTime.(Y, f; locale=locale) ) +@deprecate( + DateTime(Y::AbstractArray{<:AbstractString}, df::DateFormat=ISODateTimeFormat), + DateTime.(Y, df) ) +@deprecate( + Date(Y::AbstractArray{<:AbstractString}, f::AbstractString; locale::Locale=ENGLISH), + Date.(Y, f; locale=locale) ) +@deprecate( + Date(Y::AbstractArray{<:AbstractString}, df::DateFormat=ISODateFormat), + Date.(Y, df) ) +@deprecate( + format(Y::AbstractArray{<:TimeType}, f::AbstractString; locale::Locale=ENGLISH), + format.(Y, f; locale=locale) ) +@deprecate( + format(Y::AbstractArray{T}, df::DateFormat=default_format(T)) where {T<:TimeType}, + format.(Y, df) ) + +@deprecate +(a::GeneralPeriod, b::StridedArray{<:GeneralPeriod}) broadcast(+, a, b) +@deprecate +(a::StridedArray{<:GeneralPeriod}, b::GeneralPeriod) broadcast(+, a, b) +@deprecate -(a::GeneralPeriod, b::StridedArray{<:GeneralPeriod}) broadcast(-, a, b) +@deprecate -(a::StridedArray{<:GeneralPeriod}, b::GeneralPeriod) broadcast(-, a, b) + +# #24258 +# Physical units define an equivalence class: there is no such thing as a step of "1" (is +# it one day or one second or one nanosecond?). So require the user to specify the step +# (in physical units). +@deprecate colon(start::T, stop::T) where {T<:DateTime} start:Day(1):stop +@deprecate colon(start::T, stop::T) where {T<:Date} start:Day(1):stop +@deprecate colon(start::T, stop::T) where {T<:Time} start:Second(1):stop + +@deprecate range(start::DateTime, len::Integer) range(start, Day(1), len) +@deprecate range(start::Date, len::Integer) range(start, Day(1), len) + diff --git a/base/dates/io.jl b/stdlib/Dates/src/io.jl similarity index 100% rename from base/dates/io.jl rename to stdlib/Dates/src/io.jl diff --git a/base/dates/parse.jl b/stdlib/Dates/src/parse.jl similarity index 100% rename from base/dates/parse.jl rename to stdlib/Dates/src/parse.jl diff --git a/base/dates/periods.jl b/stdlib/Dates/src/periods.jl similarity index 100% rename from base/dates/periods.jl rename to stdlib/Dates/src/periods.jl diff --git a/base/dates/query.jl b/stdlib/Dates/src/query.jl similarity index 100% rename from base/dates/query.jl rename to stdlib/Dates/src/query.jl diff --git a/base/dates/ranges.jl b/stdlib/Dates/src/ranges.jl similarity index 100% rename from base/dates/ranges.jl rename to stdlib/Dates/src/ranges.jl diff --git a/base/dates/rounding.jl b/stdlib/Dates/src/rounding.jl similarity index 100% rename from base/dates/rounding.jl rename to stdlib/Dates/src/rounding.jl diff --git a/base/dates/types.jl b/stdlib/Dates/src/types.jl similarity index 100% rename from base/dates/types.jl rename to stdlib/Dates/src/types.jl diff --git a/test/dates/accessors.jl b/stdlib/Dates/test/accessors.jl similarity index 100% rename from test/dates/accessors.jl rename to stdlib/Dates/test/accessors.jl diff --git a/test/dates/adjusters.jl b/stdlib/Dates/test/adjusters.jl similarity index 100% rename from test/dates/adjusters.jl rename to stdlib/Dates/test/adjusters.jl diff --git a/test/dates/arithmetic.jl b/stdlib/Dates/test/arithmetic.jl similarity index 100% rename from test/dates/arithmetic.jl rename to stdlib/Dates/test/arithmetic.jl diff --git a/test/dates/conversions.jl b/stdlib/Dates/test/conversions.jl similarity index 100% rename from test/dates/conversions.jl rename to stdlib/Dates/test/conversions.jl diff --git a/test/dates/io.jl b/stdlib/Dates/test/io.jl similarity index 100% rename from test/dates/io.jl rename to stdlib/Dates/test/io.jl diff --git a/test/dates/periods.jl b/stdlib/Dates/test/periods.jl similarity index 100% rename from test/dates/periods.jl rename to stdlib/Dates/test/periods.jl diff --git a/test/dates/query.jl b/stdlib/Dates/test/query.jl similarity index 100% rename from test/dates/query.jl rename to stdlib/Dates/test/query.jl diff --git a/test/dates/ranges.jl b/stdlib/Dates/test/ranges.jl similarity index 98% rename from test/dates/ranges.jl rename to stdlib/Dates/test/ranges.jl index 576f5efd7e7de9..699c064904baf4 100644 --- a/test/dates/ranges.jl +++ b/stdlib/Dates/test/ranges.jl @@ -549,3 +549,9 @@ a = Dates.Time(23, 1, 1) @test all(x->sort(x) == (step(x) < zero(step(x)) ? reverse(x) : x), drs) @test all(x->step(x) < zero(step(x)) ? issorted(reverse(x)) : issorted(x), drs) + +@test !(1 in Date(2017, 01, 01):Dates.Day(1):Date(2017, 01, 05)) +@test !(Complex(1, 0) in Date(2017, 01, 01):Dates.Day(1):Date(2017, 01, 05)) +@test !(π in Date(2017, 01, 01):Dates.Day(1):Date(2017, 01, 05)) +@test !("a" in Date(2017, 01, 01):Dates.Day(1):Date(2017, 01, 05)) + diff --git a/test/dates/rounding.jl b/stdlib/Dates/test/rounding.jl similarity index 100% rename from test/dates/rounding.jl rename to stdlib/Dates/test/rounding.jl diff --git a/stdlib/Dates/test/runtests.jl b/stdlib/Dates/test/runtests.jl new file mode 100644 index 00000000000000..042822cfc7a618 --- /dev/null +++ b/stdlib/Dates/test/runtests.jl @@ -0,0 +1,26 @@ +using Test +using Dates + +include("accessors.jl") +include("adjusters.jl") +include("query.jl") +include("periods.jl") +include("ranges.jl") +include("rounding.jl") +include("types.jl") +include("io.jl") +include("arithmetic.jl") +include("conversions.jl") + +######## +# Misc # +######## + +# issue #12003 +const DATE12003 = DateTime(1917,1,1) +failure12003(dt=DATE12003) = Dates.year(dt) +@test isa(failure12003(), Integer) + +@test promote_type(Nullable{Date}, Nullable{DateTime}) === Nullable{DateTime} +@test Base.promote_op(-, Nullable{DateTime}, Nullable{DateTime}) == Nullable{Base.Dates.Millisecond} + diff --git a/test/dates/types.jl b/stdlib/Dates/test/types.jl similarity index 100% rename from test/dates/types.jl rename to stdlib/Dates/test/types.jl diff --git a/test/channels.jl b/test/channels.jl index d06592bb47e03d..667a483367b1fe 100644 --- a/test/channels.jl +++ b/test/channels.jl @@ -212,7 +212,7 @@ end @async begin sleep(1.0); put!(rr2, :ok) end @async begin sleep(2.0); put!(rr3, :ok) end - et = @elapsed timedwait(callback, Dates.Second(1)) + et = @elapsed timedwait(callback, 1) # assuming that 0.5 seconds is a good enough buffer on a typical modern CPU try diff --git a/test/choosetests.jl b/test/choosetests.jl index 77f1407b9ec11d..f5211ba67559e1 100644 --- a/test/choosetests.jl +++ b/test/choosetests.jl @@ -31,7 +31,7 @@ function choosetests(choices = []) "linalg", "subarray", "core", "inference", "worlds", "keywordargs", "numbers", "subtype", "printf", "char", "strings", "triplequote", "unicode", "intrinsics", - "dates", "dict", "hashing", "iobuffer", "staged", "offsetarray", + "dict", "hashing", "iobuffer", "staged", "offsetarray", "arrayops", "tuple", "reduce", "reducedim", "random", "abstractarray", "intfuncs", "simdloop", "vecelement", "sparse", "bitarray", "copy", "math", "fastmath", "functional", "iterators", @@ -78,16 +78,6 @@ function choosetests(choices = []) tests = testnames end - datestests = ["dates/accessors", "dates/adjusters", "dates/query", - "dates/periods", "dates/ranges", "dates/rounding", "dates/types", - "dates/io", "dates/arithmetic", "dates/conversions"] - if "dates" in skip_tests - filter!(x -> (x != "dates" && !(x in datestests)), tests) - elseif "dates" in tests - # specifically selected case - filter!(x -> x != "dates", tests) - prepend!(tests, datestests) - end unicodetests = ["unicode/UnicodeError", "unicode/utf8proc", "unicode/utf8"] if "unicode" in skip_tests @@ -108,7 +98,6 @@ function choosetests(choices = []) prepend!(tests, stringtests) end - sparsetests = ["sparse/sparse", "sparse/sparsevector", "sparse/higherorderfns"] if Base.USE_GPL_LIBS append!(sparsetests, ["sparse/umfpack", "sparse/cholmod", "sparse/spqr"]) diff --git a/test/core.jl b/test/core.jl index 06fe3ee87421fd..5b20a03f5d683d 100644 --- a/test/core.jl +++ b/test/core.jl @@ -3304,11 +3304,6 @@ end @test Tuple{} === NTuple{0, Any} @test Tuple{Int} === Tuple{Int, Vararg{Integer, 0}} -# issue #12003 -const DATE12003 = DateTime(1917,1,1) -failure12003(dt=DATE12003) = Dates.year(dt) -@test isa(failure12003(), Integer) - # issue #12023 Test error checking in primitive type @test_throws ErrorException (@eval primitive type 0 SPJa12023 end) @test_throws ErrorException (@eval primitive type 4294967312 SPJb12023 end) diff --git a/test/nullable.jl b/test/nullable.jl index fcc180ccc907ac..749febc9a1c4b4 100644 --- a/test/nullable.jl +++ b/test/nullable.jl @@ -392,13 +392,11 @@ end @test promote_type(Nullable{Union{}}, Int) === Nullable{Int} @test promote_type(Nullable{Float64}, Nullable{Int}) === Nullable{Float64} @test promote_type(Nullable{Union{}}, Nullable{Int}) === Nullable{Int} -@test promote_type(Nullable{Date}, Nullable{DateTime}) === Nullable{DateTime} @test Base.promote_op(+, Nullable{Int}, Nullable{Int}) == Nullable{Int} @test Base.promote_op(-, Nullable{Int}, Nullable{Int}) == Nullable{Int} @test Base.promote_op(+, Nullable{Float64}, Nullable{Int}) == Nullable{Float64} @test Base.promote_op(-, Nullable{Float64}, Nullable{Int}) == Nullable{Float64} -@test Base.promote_op(-, Nullable{DateTime}, Nullable{DateTime}) == Nullable{Base.Dates.Millisecond} # tests for istypeequal (which uses filter, broadcast) @test istypeequal(Nullable(0), Nullable(0)) diff --git a/test/ranges.jl b/test/ranges.jl index c665fe920676a8..23809039ca4016 100644 --- a/test/ranges.jl +++ b/test/ranges.jl @@ -369,11 +369,6 @@ end @test !(π in 1.0:3.0) @test !("a" in 1:3) @test !("a" in 1.0:3.0) - @test !(1 in Date(2017, 01, 01):Dates.Day(1):Date(2017, 01, 05)) - @test !(Complex(1, 0) in Date(2017, 01, 01):Dates.Day(1):Date(2017, 01, 05)) - @test !(π in Date(2017, 01, 01):Dates.Day(1):Date(2017, 01, 05)) - @test !("a" in Date(2017, 01, 01):Dates.Day(1):Date(2017, 01, 05)) - end end @testset "indexing range with empty range (#4309)" begin @test (3:6)[5:4] == 7:6 diff --git a/test/threads.jl b/test/threads.jl index 278fa9181c4454..47b21aa161c2a1 100644 --- a/test/threads.jl +++ b/test/threads.jl @@ -347,8 +347,7 @@ for T in (Int32, Int64, Float32, Float64) @test varmax[] === T(maximum(1:nloops)) @test varmin[] === T(0) end -for period in (0.06, Dates.Millisecond(60)) - let async = Base.AsyncCondition(), t +let period = 0.06, async = Base.AsyncCondition(), t c = Condition() task = schedule(Task(function() notify(c)