Skip to content

Failed to create ZonedDateTime range in Julia 1.9.2 #440

@JakubPorubcansky

Description

@JakubPorubcansky

In Julia 1.7.3, the following code is working

julia> using Dates, TimeZones

julia> range(ZonedDateTime(2007, 03, 24, tz"Europe/Budapest"), length=6, step=Hour(1))
ZonedDateTime(2007, 3, 24, tz"Europe/Budapest"):Hour(1):ZonedDateTime(2007, 3, 24, 5, tz"Europe/Budapest")

julia> versioninfo()
Julia Version 1.7.3
Commit 742b9abb4d (2022-05-06 12:58 UTC)
Platform Info:
  OS: Windows (x86_64-w64-mingw32)
  CPU: Intel(R) Core(TM) i5-7200U CPU @ 2.50GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-12.0.1 (ORCJIT, skylake)

(@v1.7) pkg> status TimeZones
      Status `C:\Users\jakub\.julia\environments\v1.7\Project.toml`
  [f269a46b] TimeZones v1.11.0

but after upgrading to Julia 1.9.2, it does not work anymore

julia> using Dates, TimeZones

julia> range(ZonedDateTime(2007, 03, 24, tz"Europe/Budapest"), length=6, step=Hour(1))
Error showing value of type StepRangeLen{ZonedDateTime, ZonedDateTime, Hour, Int64}:
ERROR: MethodError: no method matching ZonedDateTime(::ZonedDateTime)

Closest candidates are:
  ZonedDateTime(::Union{Period, TimeZone}...)
   @ TimeZones C:\Users\jakub\.julia\packages\TimeZones\miNCa\src\types\zoneddatetime.jl:136
  ZonedDateTime(::AbstractString)
   @ TimeZones C:\Users\jakub\.julia\packages\TimeZones\miNCa\src\parse.jl:86
  ZonedDateTime(::AbstractString, ::AbstractString; locale)
   @ TimeZones C:\Users\jakub\.julia\packages\TimeZones\miNCa\src\parse.jl:100
  ...

Stacktrace:
  [1] unsafe_getindex(r::StepRangeLen{ZonedDateTime, ZonedDateTime, Hour, Int64}, i::Int64)
    @ Base .\range.jl:948
  [2] first(r::StepRangeLen{ZonedDateTime, ZonedDateTime, Hour, Int64})
    @ Base .\range.jl:826
  [3] show(io::IOContext{Base.TTY}, r::StepRangeLen{ZonedDateTime, ZonedDateTime, Hour, Int64})
    @ Base .\range.jl:0
  [4] show(io::IOContext{Base.TTY}, #unused#::MIME{Symbol("text/plain")}, r::StepRangeLen{ZonedDateTime, ZonedDateTime, Hour, Int64})
    @ Base .\show.jl:13
  [5] (::OhMyREPL.var"#7#8"{REPL.REPLDisplay{REPL.LineEditREPL}, MIME{Symbol("text/plain")}, Base.RefValue{Any}})(io::IOContext{Base.TTY})
    @ OhMyREPL C:\Users\jakub\.julia\packages\OhMyREPL\zRJyJ\src\output_prompt_overwrite.jl:23
  [6] with_repl_linfo(f::Any, repl::REPL.LineEditREPL)
    @ REPL C:\Users\jakub\AppData\Local\Programs\Julia-1.9.2\share\julia\stdlib\v1.9\REPL\src\REPL.jl:557
  [7] display
    @ C:\Users\jakub\.julia\packages\OhMyREPL\zRJyJ\src\output_prompt_overwrite.jl:6 [inlined]
  [8] display
    @ C:\Users\jakub\AppData\Local\Programs\Julia-1.9.2\share\julia\stdlib\v1.9\REPL\src\REPL.jl:281 [inlined]
  [9] display(x::Any)
    @ Base.Multimedia .\multimedia.jl:340
 [10] #invokelatest#2
    @ .\essentials.jl:816 [inlined]
 [11] invokelatest
    @ .\essentials.jl:813 [inlined]
 [12] print_response(errio::IO, response::Any, show_value::Bool, have_color::Bool, specialdisplay::Union{Nothing, AbstractDisplay})
    @ REPL C:\Users\jakub\AppData\Local\Programs\Julia-1.9.2\share\julia\stdlib\v1.9\REPL\src\REPL.jl:305
 [13] (::REPL.var"#57#58"{REPL.LineEditREPL, Pair{Any, Bool}, Bool, Bool})(io::Any)
    @ REPL C:\Users\jakub\AppData\Local\Programs\Julia-1.9.2\share\julia\stdlib\v1.9\REPL\src\REPL.jl:287
 [14] with_repl_linfo(f::Any, repl::REPL.LineEditREPL)
    @ REPL C:\Users\jakub\AppData\Local\Programs\Julia-1.9.2\share\julia\stdlib\v1.9\REPL\src\REPL.jl:557
 [15] print_response(repl::REPL.AbstractREPL, response::Any, show_value::Bool, have_color::Bool)
    @ REPL C:\Users\jakub\AppData\Local\Programs\Julia-1.9.2\share\julia\stdlib\v1.9\REPL\src\REPL.jl:285
 [16] (::REPL.var"#do_respond#80"{Bool, Bool, REPL.var"#93#103"{REPL.LineEditREPL, REPL.REPLHistoryProvider}, REPL.LineEditREPL, REPL.LineEdit.Prompt})(s::REPL.LineEdit.MIState, buf::Any, ok::Bool)
    @ REPL C:\Users\jakub\AppData\Local\Programs\Julia-1.9.2\share\julia\stdlib\v1.9\REPL\src\REPL.jl:899
 [17] #invokelatest#2
    @ .\essentials.jl:816 [inlined]
 [18] invokelatest
    @ .\essentials.jl:813 [inlined]
 [19] run_interface(terminal::REPL.Terminals.TextTerminal, m::REPL.LineEdit.ModalInterface, s::REPL.LineEdit.MIState)
    @ REPL.LineEdit C:\Users\jakub\AppData\Local\Programs\Julia-1.9.2\share\julia\stdlib\v1.9\REPL\src\LineEdit.jl:2647
 [20] run_frontend(repl::REPL.LineEditREPL, backend::REPL.REPLBackendRef)
    @ REPL C:\Users\jakub\AppData\Local\Programs\Julia-1.9.2\share\julia\stdlib\v1.9\REPL\src\REPL.jl:1300
 [21] (::REPL.var"#62#68"{REPL.LineEditREPL, REPL.REPLBackendRef})()
    @ REPL .\task.jl:514

julia> versioninfo()
Julia Version 1.9.2
Commit e4ee485e90 (2023-07-05 09:39 UTC)
Platform Info:
  OS: Windows (x86_64-w64-mingw32)
  CPU: 4 × Intel(R) Core(TM) i5-7200U CPU @ 2.50GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-14.0.6 (ORCJIT, skylake)
  Threads: 1 on 4 virtual cores
Environment:
  JULIA_IMAGE_THREADS = 1

(@v1.9) pkg> status TimeZones
Status `C:\Users\jakub\.julia\environments\v1.9\Project.toml`
  [f269a46b] TimeZones v1.11.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions