FAQ
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

Search Discussions

  • Flavio S. Glock at Nov 30, 2013 at 3:09 pm
    For a DateTime::SpanSet object, you can call ->duration(), it returns
    a DateTime::Duration object.

    Iterating over the spans also work.

    2013/11/29 Andreas Isberg <andreas.isberg@gmail.com>:
    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

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupdatetime @
categoriesperl
postedNov 29, '13 at 11:59a
activeNov 30, '13 at 3:09p
posts2
users2
websitemetacpan.org...

2 users in discussion

Flavio S. Glock: 1 post Andreas Isberg: 1 post

People

Translate

site design / logo © 2019 Grokbase