http://qs321.pair.com?node_id=1051781

biohisham has asked for the wisdom of the Perl Monks concerning the following question:

Hello Monks after a wee while. Well, I have a weird situation with DateTime::Duration when I am adding values of the format [hh:mm::ss] together. The normalization of the seconds into minutes after 59 seems to be not doing what should exactly be done when the total of the seconds is over 59. In my case seconds just get added up well beyond this rather than be converted to minutes. However, minutes seamlessly get converted into hours with no glitches. I tried a few tricks in the documentation of DateTime::Duration regarding the addition of [hh:mm::ss] values but all producing the same result.

Is this a behavior to expect with this module ? or it got to do with the way I wrote my program. And since it is one of the very robust modules out there I still saw that many other similar modules offering date and time calculation don't weigh in such straightforward additions and subtraction of values

Here's a functioning code that reproduces the case I am describing. After adding up all the hh:mm::ss values I get this output Total Time: 11:57:300

use strict; use warnings; use DateTime::Duration; my $duration = DateTime::Duration->new(); while(<DATA>){ chomp; my ($hour, $minute, $second); my @time = split(':',$_); if(scalar @time == 3){ ($hour, $minute, $second) = @time; $duration->add(hours=>$hour, minutes=>$minute, seconds=>$secon +d); }elsif(scalar @time == 2){ $hour =0; ($minute, $second) = @time; $duration->add(hours=>$hour, minutes=>$minute, seconds=>$s +econd); } } print "Total Time: ", join(':',$duration->in_units('hours', 'minutes', +'seconds')),$/; __DATA__ 5:43:05 01:18 11:25 36:31 17:14 20:14 07:55 06:50 00:40 23:33 1:18:02 2:55:13

David R. Gergen said "We know that second terms have historically been marred by hubris and by scandal." and I am a two y.o. monk today :D, June,12th, 2011...