Re: datetime:diff() question
- Posted by Ekhnat0n Dec 08, 2017
- 1383 views
Hello mr davis,
If you were asked the difference between 3 and 8, what would be your answer?
Let me guess.... 5
If I am correct, you have DEDUCTED 3 from 8 as everybody would do.
However I would (maybe) have answered MINUS 5, because I deducted 8 from 3, using Reverse Polish Notation
Hence the function diff(a,b) does exactly what you yourself did.
Regards,
Antoine
Under the hood, this function almost certainly looks like
function diff(object a,b)
if a<b then return b-a
else return a-b
end
OR
function diff(object a,b) return ABS(a-b) end
BECAUSE for finding the difference you will have to deduct the lower value from the higher one, not the 2nd argument from the 1st