-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Various Date/Time fixes #20226
Various Date/Time fixes #20226
Conversation
you're deleting a lot of recent news additions here, probably wrong local conflict resolution? |
@@ -219,15 +212,11 @@ Library improvements | |||
|
|||
* `notify` now returns a count of tasks woken up ([#19841]). | |||
|
|||
* A new `Dates.Time` type was added that supports representing the time of day with up to nanosecond resolution. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should add PR reference
($op){T<:TimeType,P<:GeneralPeriod}(x::StridedArray{P}, y::T) = broadcast($op,x,y) | ||
($op){P<:GeneralPeriod}(y::TimeType, x::StridedArray{P}) = broadcast($op,x,y) | ||
($op){T<:TimeType}(x::AbstractArray{T}, y::GeneralPeriod) = broadcast($op, x, y) | ||
($op){P<:GeneralPeriod}(y::TimeType, x::StridedArray{P}) = broadcast($op, x, y) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shouldn't this one be addition-only? or be sure the argument orders match?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you rebased this one back
(+)(x::Date, y::Day) = return Date(UTD(value(x) + value(y))) | ||
(-)(x::Date, y::Day) = return Date(UTD(value(x) - value(y))) | ||
(+)(x::DateTime, y::Period) = return DateTime(UTM(value(x) + toms(y))) | ||
(-)(x::DateTime, y::Period) = return DateTime(UTM(value(x) - toms(y))) | ||
(+)(x::Time, y::TimePeriod) = return Time(Nanosecond(value(x) + tons(y))) | ||
(-)(x::Time, y::TimePeriod) = return Time(Nanosecond(value(x) - tons(y))) | ||
(+)(y::Period, x::TimeType) = x + y | ||
(-)(y::Period, x::TimeType) = x - y |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know who might be finding these useful, but it would be a bit less disruptive to phase it out with a warning in deprecated.jl.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think anybody's relying on it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would seem crazy to think this would work, so it's hard to imagine relying on this. In other words, imo deleting this method is a bugfix not a feature deletion.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
both #12094 and #12115 mention this which is why I pinged @GordStephen for input, but he might not be using julia as much lately, not sure
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would agree that this is crazy and more likely an oversight on my part than any kind of feature. I'm certainly not using this functionality.
for p in y.periods | ||
x -= p | ||
end | ||
return x | ||
end | ||
(-)(x::CompoundPeriod,y::TimeType) = y - x | ||
(-)(x::CompoundPeriod, y::TimeType) = y - x |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
another instance of commutative subtraction that should be deprecated
(looks like @GordStephen may have been the author of a few of these)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
likewise I think your rebase lost the removal of this
if op == :+ | ||
@eval begin | ||
($op){T<:TimeType}(y::GeneralPeriod, x::AbstractArray{T}) = broadcast($op, x, y) | ||
($op){T<:TimeType,P<:GeneralPeriod}(x::StridedArray{P}, y::T) = broadcast($op, x, y) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
since the argument order of this one is x, y
on both lhs and rhs I think this one is fine to have defined for subtraction
If you need a hand rebasing this, I can take a look late tonight. Just that one method to make a decision on. This addresses basically all of the feedback I had on the Time PR. |
I'll see if I can get to this; if not, feel free to go for it. I've been having computer issues and had to try and get my windows machine set back up for julia dev last night and had struggles. |
Rebasing now |
4b6d77b
to
48f1bc2
Compare
@@ -86,11 +86,11 @@ for op in (:+, :-) | |||
@eval begin | |||
($op){T<:TimeType}(x::AbstractArray{T}, y::GeneralPeriod) = broadcast($op, x, y) | |||
($op){P<:GeneralPeriod}(y::TimeType, x::StridedArray{P}) = broadcast($op, x, y) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this one's bad though
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wait, why is this one bad?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the argument order is y, x on the left and x, y on the right so it only works for commutative ops
Travis is happy; @tkelman anything else to be changed here? |
|
@tkelman, could you fix the rebase for me? I unfortunately don't have access to my computer and my windows machine is all jacked. If you can't, I can probably get to it later tonight. |
Okay done. The dates tests fail if run with |
@@ -314,63 +314,62 @@ emptyperiod = ((y + d) - d) - y | |||
@test Dates.canonicalize(y - m + w - d + h - mi + s - ms).periods == Dates.Period[11m, 6d, 59mi, 999ms] | |||
@test Dates.canonicalize(-y + m - w + d - h + mi - s + ms).periods == Dates.Period[-11m, -6d, -59mi, -999ms] | |||
|
|||
@test Dates.Date(2009,2,1) - (Dates.Month(1) + Dates.Day(1)) == Dates.Date(2008,12,31) | |||
@test (Dates.Month(1) + Dates.Day(1)) - Dates.Date(2009,2,1) == Dates.Date(2008,12,31) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe this should be left in to ensure this behaviour throws an exception?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea. Added back as @test_throws
cf95a04
to
8671e14
Compare
(+)(a::TimeType, b::Period, c::Period) = (+)(a, b + c) | ||
(-)(a::TimeType, b::Period, c::Period) = (-)(a, b - c) | ||
(+)(a::TimeType, b::Period, c::Period, d::Period...) = (+)((+)(a, b + c), d...) | ||
(-)(a::TimeType, b::Period, c::Period, d::Period...) = (-)((-)(a, b - c), d...) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there's some strange associativity here too... if a - b - c
is a - (b - c)
, then shouldn't a - b - c - d
be a - (b - (c - d))
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tests pass without them, should we get rid of these subtractions too?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1
unless someone tells me otherwise
No description provided.