>
> Is there any reason to use it in preference to DateTime::Duration?
Hi Aristotle,
My module differs from DateTime::Duration because it is not dealing with dates. It
does not try to foresee which is a future of past
date based in a bunch of seconds.
It just provide a means to calculate a "time quantity" that is more human readable
than a big number of seconds.
For example, if you're making a big file transfer over the network everyday, and this
transfer takes 7341 seconds to finish, and you
want to receive a report saying how much time the transfer took, indeed, you want to
know that the file transfer took 2 hours, 2
minutes and 21 seconds (7341 seconds "grouped by" hours).
My module will calculate this conversion of seconds to a bigger "time group", HOURS,
in this case.
To do this with my module you would:
# - converting seconds to hours -
new $time = new Time::Seconds::GroupedBy('HOURS');
my ($secs, $mins, $hours) = $time->calculate(7341);
print "$hours hours $mins minutes $secs seconds\n";
So, if you have more seconds to calculate, maybe hours is a small quantity, then you
may chose to group seconds in a bigger group,
like DAYS. For example, to know that 734100 seconds are equivalent to 8 days, 11
hours, 55 mins, 0 seconds.
# - converting seconds to days -
$time->groubBy('DAYS');
my ($secs, $mins, $hours, $days) = $time->calculate(734100);
When "DAYS" is a small group, you could group them by "MONTHS", ultimately, by "YEARS".
Well, it's usefull for me. I didn't find yet a module providing this kind of
conversion...
what do you think?
A hug,
bruno.