Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Creating range of ZonedDateTime, 2 inconsistencies with DateTime version #104

Closed
JockLawrie opened this issue Dec 15, 2017 · 3 comments
Closed

Comments

@JockLawrie
Copy link

Hi there,

I am creating a range of ZonedDateTime, using Julia 0.6.1.

Using only Base.DateTime I do the following, and all is well:

using Base.Dates
dttm1 = DateTime("2017-10-01 09:00", "Y-m-d H:M")
dttm2 = DateTime("2017-12-08 23:00", "Y-m-d H:M")
r = dttm1:dttm2

Using ZonedDateTime I do the following:

using Base.Dates
using TimeZones
tz    = TimeZone("Australia/Melbourne")
dttm1 = ZonedDateTime(DateTime("2017-10-01 09:00", "Y-m-d H:M"), tz)
dttm2 = ZonedDateTime(DateTime("2017-12-08 23:00", "Y-m-d H:M"), tz)
r = dttm1:dttm2

Although both versions work, I see 2 issues:

  1. The DateTime version has stepsize of 1 day, whereas the ZonedDateTime version has stepsize 1 millisecond.
  2. The ZonedDateTime version gives the following deprecation warning:
WARNING: convert(::Type{T}, x::Real) where T <: Dates.Period is deprecated, use T(x) instead.
Stacktrace:
 [1] depwarn(::String, ::Symbol) at ./deprecated.jl:70
 [2] convert(::Type{Base.Dates.Millisecond}, ::Int64) at ./deprecated.jl:57
 [3] colon(::TimeZones.ZonedDateTime, ::TimeZones.ZonedDateTime) at ./range.jl:9
 [4] eval(::Module, ::Any) at ./boot.jl:235
 [5] eval_user_input(::Any, ::Base.REPL.REPLBackend) at ./REPL.jl:66
 [6] macro expansion at ./REPL.jl:97 [inlined]
 [7] (::Base.REPL.##1#2{Base.REPL.REPLBackend})() at ./event.jl:73
while loading no file, in expression starting on line 0

Are these 2 issues real and to be fixed?
Or is my understanding flawed and I should be doing something different?

Thanks,
Jock

@omus
Copy link
Member

omus commented Dec 15, 2017

Thanks for filing this issue Jock.

  1. The DateTime version has stepsize of 1 day, whereas the ZonedDateTime version has stepsize 1 millisecond.

I think having the step size default to be 1 day is much more reasonable than the current 1 millisecond. I'll note however that in Julia 0.7 that specifying a DateTime range without a step is deprecated:

julia> DateTime(2000,1):DateTime(2000,2)
WARNING: colon(start::T, stop::T) where T <: DateTime is deprecated, use start:Day(1):stop instead.

I'll address this for Julia 0.6 however.

  1. The ZonedDateTime version gives the following deprecation warning:

That warning is mostly due to me not setting a default step in Julia 0.6. Essentially the issue is that oftype calls convert(::Type{<:Period}, ::Real) which has been deprecated in favor of using T(x). Details about this can be found in this issue.

Don't worry about the deprecation warning as I'll address this with the fix to 1. Thanks again for the report.

@JockLawrie
Copy link
Author

Thanks for replying.
No need to change. If the absence of a step size is deprecated for Julia 0.7 we may as well get used to it now.

Thanks again,
Jock

@omus
Copy link
Member

omus commented Dec 18, 2017

I would definitely advise that you specify a step size. That said I'll still be changing the default for 0.6 to avoid confusion with the warning you saw and it'll allow me to introduce a deprecation in 0.7.

@omus omus closed this as completed in #105 Jan 12, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants