Re: How to get a DateTime::SpanSet duration in seconds for doing math?
[email protected] ("Flavio S. Glock") Sat, 30 Nov 2013 16:09:25 +0100
| Newsgroups | perl.datetime |
|---|---|
| Message-ID | <CAHMRfDxLFradXp7fTN20yg4BpsNHYBNbMH=dPt=dOpEZGxJ6FQ@mail.gmail.com> |
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 <[email protected]>: > 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