I'm trying to do a '>' comparison between two relativedeltas:
if(relativedelta(current_date, last_activity_date) > relativedelta(minutes=15)):
Here is the output from the debugger window in Eclipse:
One of the relativedeltas is only 15 minutes-- far smaller than the other one. Why does this comparison return false and not true as expected? What would be a better solution?
dateutil.relativedelta
doesn't implement __cmp__
sensibly, so instances can't be compared. There's an open bug on the issue; the argument that it doesn't make sense to say whether 29 days or 1 month is greater, and that therefore the whole thing falls back on python's default comparisons seems a bit flimsy to me, but that's just an opinion.
Depending on what you're actually doing, using datetime.timedelta
may be a better solution.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With