On Tue, 11 Nov 2003, Max Maischein wrote:
> after some thinking about how to compare the "inconvertible" units, I
> came up with an ugly hack that will work for "most" cases - the border
> cases where it fails, are not yet detected, but I'm working on that. The
> patch passes all my ad-hoc tests, I'll run it later against the DateTime
> test suite.
You can't possibly detect the border cases because they only exist in the
context of a "base" datetime to which the durations are added. That's the
fundamental problem of trying to compare durations.
> sub _normalize_sign {
> my $self = shift;
> my $minutes = $self->{minutes};
>
> # A day is longer than (or equal to) 23 hours,
> # a month is longer than (or equal to) 28 days a 24 hours, as DST is
> never in february:
DST changes may not occur in February, but time zone offset changes can,
because these can occur due to legislation.
> $minutes += $self->{days} * 23 * 60;
> $minutes += $self->{months} * 24 * 60 * 28;
>
> $self->{sign} = 0 <=> $minutes;
> };
This is a vague approximation that won't work in all cases. How would we
document this? It's incredibly complicated to explain.
-dave
/*=======================
House Absolute Consulting
www.houseabsolute.com
=======================*/