Just a quick question, maybe I just don't understand something. I
have code that compares new and old values of object attributes
before assigning the new value. If the attribute has not been
changed, I don't bother to assign. However, this doesn't work with
DateTime::Duration attributes, because comparison is overloaded to
throw an exception. My question is this: What's the reason not to
overload comparison? I don't really follow the justification in the
docs:
If no base datetime is given, then the result of DateTime->now is
used instead. Using this default will give non-repeatable results
if used to compare two duration objects containing different units.
It will also give non-repeatable results if the durations contain
multiple types of units, such as months and days.
However, if you know that both objects only contain the same units,
and just a single type, then the results of the comparison will be
repeatable.
I guess that means that sometimes, one can get different answers for
different nows(). But all I'm really interested in is whether the
Duration object has a different duration than another object. IOW,
are they identical to each other? The time that they're assigned to
is not really relevant to me.
So is there perhaps a simpler way to just compare Duration objects?
Thanks!
David