How to get a DateTime::SpanSet duration in seconds for doing math?

2013-11-29 Thread Andreas Isberg
Hi, I'm trying to find a way to perform math with the duration of a
DateTime::SpanSet. I'd prefer it to be in seconds, but I can't find
anything from it in the documentation.

What I did find is that the DateTime module has a
*subtract_datetime_absolute* function that would give me seconds and
nanoseconds from two DateTime objects.
So I guess one way to do this is to iterate over the entire
DateTime::SpanSet, and for all DateTime::Span
perform subtract_datetime_absolute for the start and end of it, and sum it
all. I haven't tried this yet tho..

Would this approach work, or is there any other better way?

Kind regards,
Andreas Isberg
Telefon: 072-588 91 95


Removing spans from a spanset with grep returns unexpected results?

2013-10-14 Thread Andreas Isberg
Hi,

I'm using the DateTime::SpanSet module and I'm looking for a way to reduce
my set by removing spans containing an infinite value (more precise
span->start and span->end).
I've tried the following:

$spanset = $spanset->grep(
sub {
return !($_->start->is_infinite() || $_->end->is_infinite());
}
);

This returns a DateTime::SpanSet consisting of DateTime::Span items. So far
so good.
But the the start and end of each Span is itself a Span, and not DateTime
objects as I was expecting.

Any clues what I'm doing wrong?

Kind regards,
Andreas Isberg


DateTime::Duration->compare() return value is not specified in the documentation.

2013-10-10 Thread Andreas Isberg
Hi,

The documentation does not specify what What does
DateTime::Duration->compare() returns.

>From some testing I've done it seems like it

   - 1 if the first duration is larger than the second,
   - 0 if the durations are equal
   - -1 is the second duration is larger than the first

Can anyone confirm this, and possibly update the documentation?

Documentation is found here:
http://search.cpan.org/~drolsky/DateTime-1.03/lib/DateTime/Duration.pm#DateTime::Duration->compare(_$duration1,_$duration2,_$base_datetime_)

Kind regards,
Andreas Isberg
Telefon: 072-588 91 95


Determine size of a DateTime::SpanSet?

2013-09-04 Thread Andreas Isberg
Hi,

I'm looking for a way to find the size of a DateTime::SpanSet, i.e. the
number of DateTime:Span objects in it.

I'm not looking for a DateTime::Duration object, as the size() method
returns.

Kind regards,
Andreas