> On Mon, 10 Nov 2003, Jonathan Swartz wrote:
>
> > Thanks. You might want to explain why comparison isn't offered (whether
it's
> > the reason I mentioned above, or another reason), and give some hints
about
> > what to do if you have to compare two durations (e.g. add them each to a
> > single reference time and compare the resulting times.)
>
> Well, that still doesn't say which is bigger.  For example, 1 month is
> smaller than 30 days if your base date is Feb 1, but not if it's December
> 1.  It might be useful if you know that both durations were originally
> derived from a single base datetime, but otherwise it's not terribly
> useful.

True, it isn't useful if you want to compare absolutely arbitrary durations
and get a reliable answer. But in my case, I was dealing with durations
defined in hours and minutes, and guaranteed to be less than a day, so the
comparison would pretty much work anchored at any date. * I'd guess that
many DateTime applications have constraints like that which would allow
worry-free comparisons.

Maybe it's better to offer the comparison operators (by anchoring at present
time) and give ample warnings in the documentation about the cases where it
won't work reliably.

Jon

* - yes, I'm sure you date experts will ravenously point out certain Julian
epochs where an hour was only 58 minutes or something. give me a little
slack, ok? :)

Reply via email to