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
Missing division of time periods #29395
Comments
The problem is that there is no unique answer here. Consider |
Right, it should only be done for units that can be converted. julia> convert(Millisecond, Year(1))
ERROR: MethodError: Cannot `convert` an object of type Year to an object of type Millisecond
Closest candidates are:
convert(::Type{Millisecond}, ::Second) at /Users/osx/buildbot/slave/package_osx64/build/usr/share/julia/stdlib/v0.7/Dates/src/periods.jl:421
convert(::Type{Millisecond}, ::Minute) at /Users/osx/buildbot/slave/package_osx64/build/usr/share/julia/stdlib/v0.7/Dates/src/periods.jl:421
convert(::Type{Millisecond}, ::Hour) at /Users/osx/buildbot/slave/package_osx64/build/usr/share/julia/stdlib/v0.7/Dates/src/periods.jl:421
...
Stacktrace:
[1] top-level scope at none:0
julia> convert(Millisecond, Day(1))
86400000 milliseconds Converting the bigger of the two units to the smaller unit seems like the best way to go about it. |
in that case, only second to millisecond should work, as leap seconds allow impression for all larger units |
it's unfortunate, but time units really sex sic suck |
I think that julia> DateTime(2017, 2) + (Day(30) + Month(1))
2017-03-31T00:00:00
julia> (DateTime(2017, 2) + Day(30)) + Month(1)
2017-04-03T00:00:00 In any case, all I'm asking is for |
This has been implemented in #43360 julia> Minute(10) / Millisecond(1)
600000.0 |
Currently,
If division is supported at all, it would be very convenient to be able to divide across compatible units.
The text was updated successfully, but these errors were encountered: