This is from https://rt.cpan.org/Ticket/Display.html?id=59331

On Thu Jul 15 13:50:14 2010, [email protected] wrote:
> On Thu, 15 Jul 2010, Paul Miller via RT wrote:
> > sub seconds     { abs( $_[0]->in_units('seconds') ) }
>
> Well, that looks different to me but ...

How is seconds() different from in_units("seconds")?  I don't see it.
It doesn't produce the length of the duration in seconds.  It produces
subjectively speaking, the wrong numbers... rather the remainder after
some other invisible conversion.  I get what it's doing.  I just think
you're intentionally limiting the usefulness of the duration object.

> Have you read the DateTime.pm docs in detail? It explains some of this.

I have.  I just don't understand why duration objects can't tell me
their duration in the units I want and why it returns anything at all
if it's actually refusing to do the conversion to seconds.  The
documents say it won't do the conversion and makes a religious stance
about it.  My thinking is that it should raise an exception or
something instead.

> If you want the difference in seconds, you can use the method I suggested.
> Or you can just argue with me if that's more fun for you, but I may stop
> participating in the argument ;)

It's not just for fun.  I'm trying to be helpful. DateTime is clearly
the future of date processing in Perl and right now I find Date::Manip
and Date::Calc a whole lot easier to deal with.  I understand there's
ambiguity here, but I think there are some predictably acceptable
conversions that can be done (4 weeks in a month, 7 days in a week,
etc); and they could at least be an option.

> It returns the duration in X units. So a duration could be 2 months, 3
> days, 4 hours, and 5 seconds. There's no way to determine a length in
> seconds from that.

There is, but people may not generally agree on the units.  You could
just make them adjustable or come up with a standard that people can
agree on, or maybe produce an error when it seems clear someone is
trying to do a conversion that doesn't make sense to you.


-Paul

-- 
If riding in an airplane is flying, then riding in a boat is swimming.
116 jumps, 48.6 minutes of freefall, 92.9 freefall miles.

Reply via email to