hmm… interesting. I would also have thought it is implemented, given +
, and -
are already implemented.
Well, here is my attempt, using differences.
function duration_gt(x::Dates.CompoundPeriod, y::Dates.CompoundPeriod)
d = y-x
# probably bad assumption that the first period is always
# the lower time resolution and canonicalized?
first(d.periods).value < 0
end
duration_gt(x::Dates.CompoundPeriod, y::Dates.Period) = duration_gt(x,Dates.CompoundPeriod(y))
duration_gt(x::Dates.Period, y::Dates.CompoundPeriod) = duration_gt(Dates.CompoundPeriod(x),y)
duration_gt(x::Dates.Period, y::Dates.Period) = duration_gt(Dates.CompoundPeriod(x),Dates.CompoundPeriod(y))
Some quick test cases:
julia> W1D1 = Week(1)+Day(1)
1 week, 1 day
julia> S2 = Second(2)
2 seconds
julia> MS300 = Microsecond(300)
300 microseconds
julia> duration_gt(W1D1,S2)
true
julia> duration_gt(S2,W1D1)
false
julia> duration_gt(S2,MS300)
true
julia> duration_gt(MS300,S2)
false
I think it is not implemented, because Year
and Month
are not fixed duration, it doesn’t work with CompoundPeriond with Month
or Year
in it.