-------- Original Message --------
Subject: Re: [Fwd: DateTime::Duration comparisions]
Date: Thu, 13 Nov 2003 10:16:25 +0100
From: Max Maischein <[EMAIL PROTECTED]>
To: Dave Rolsky <[EMAIL PROTECTED]>
References: <[EMAIL PROTECTED]> <[EMAIL PROTECTED]>
Dave Rolsky wrote:
I wrote a test file that shows some ugly bugs when dealing with my naive comparision, most notably that ($dt-$dt)->is_zero() is false. I don't know why you implemented is_zero() that way, so I can't propose any good change. My approach would be to make is_zero() not only check the sign but also check whether all values are zero.
Yeah, the is_* bits for durations are all screwed up. I'm considering removing them, because I'm not sure we can fix them and still do interesting thing with durations.
At least the is_zero thing can easily be fixed. For the other is_* methods, only my ugly approximation or some other threshold-based approach can be made. I now understand some of the problems you face, but I still think that a ::Duration should DWIM as far as possible.
looking at DateTime::Duration, as I could not find an easy way to look at two DateTime objects and find out which one was later, as comparision for those also isn't implemented (or, once again, I'm too stupid to read the docs properly).Now I'm really confused. DateTime.pm objects have _always_ had a compare method, plus they overload comparison operators.
Somehow I must have been really stupid that day, as now, DateTime comparision works ...
perl -MDateTime -le "$a=DateTime->from_epoch(epoch=>0);$b=DateTime->now(); print $a>$b?'a>b':''; print $a<$b?'a<b':'';"
I think my problem arose because I tried to check whether the distance between two points in time was larger than 30 minutes, which meant that I had to compare two DateTime::Duration objects, which isn't/wasn't possible. More on this in the next mail :-)
-max
