It appears that I cannot have a Dict with Dates.Hour(1)
and Dates.Month(1)
as keys. I can have absolutely any other type/value as a key in this Dict, but I cannot put these two keys together in the same Dict.
It does not matter what order they are added in, the second one will throw an exception about the missing ==
method, but I don’t understand that because both of these are subtypes of Base.Period
and we have ==(::Base.Dates.Period, ::Base.Dates.Period)
defined, so why wouldn’t the compiler use that?
What’s even weirder, is I can use Dates.Hour(2)
and Dates.Hour(0)
, but not Dates.Hour(1)
, and the same for Dates.Month
julia> DATEPART_DISPLAY = Dict{Dates.Period, AbstractString}()
Dict{Base.Dates.Period,AbstractString} with 0 entries
julia> DATEPART_DISPLAY[Dates.Month(1)] = "%b %Y"
"%b %Y"
julia> DATEPART_DISPLAY[Dates.Week(1)] = "%b %d %Y"
"%b %d %Y"
julia> DATEPART_DISPLAY[Dates.Hour(1)] = "%b %d %Y, %H:%M"
ERROR: MethodError: no method matching ==(::Base.Dates.Hour, ::Base.Dates.Month)
Closest candidates are:
==(::Union{Base.Dates.Day, Base.Dates.Hour, Base.Dates.Microsecond, Base.Dates.Millisecond, Base.Dates.Minute, Base.Dates.Nanosecond, Base.Dates.Second, Base.Dates.Week}, ::Union{Base.Dates.Month, Base.Dates.Year}) at dates/periods.jl:443
==(::Base.Dates.Period, ::Base.Dates.Period) at dates/periods.jl:63
==(::Any, ::Any) at operators.jl:52
...
Stacktrace:
[1] ==(::Base.Dates.Hour, ::Base.Dates.Month) at ./dates/periods.jl:443
[2] ht_keyindex2(::Dict{Base.Dates.Period,AbstractString}, ::Base.Dates.Hour) at ./dict.jl:366
[3] setindex!(::Dict{Base.Dates.Period,AbstractString}, ::String, ::Base.Dates.Hour) at ./dict.jl:421
julia> DATEPART_DISPLAY[Dates.Minute(1)] = "%b %d %Y, %H:%M"
"%b %d %Y, %H:%M"
julia> DATEPART_DISPLAY[Dates.Second(1)] = "%b %d %Y, %H:%M:%S"
"%b %d %Y, %H:%M:%S"
julia> DATEPART_DISPLAY[Dates.Year(1)] = "%Y"
"%Y"
julia> versioninfo()
Julia Version 0.6.3-pre.2
Commit c011bb7 (2018-05-08 17:03 UTC)
DEBUG build
Platform Info:
OS: Linux (x86_64-linux-gnu)
CPU: Intel(R) Core(TM) i7-4770HQ CPU @ 2.20GHz
WORD_SIZE: 64
BLAS: libopenblas (USE64BITINT DYNAMIC_ARCH NO_AFFINITY Haswell)
LAPACK: libopenblas64_
LIBM: libopenlibm
LLVM: libLLVM-3.9.1 (ORCJIT, haswell)