in reply to How to calculate the total time taken to complete the build operation

Update:  BTW, this cannot/does not handle the case where the end date is not the same as the start date. You might want to consider also including the date in your timestring to account for this case (you'll need to also modify my code a bit...)


Here's a "down-n-dirty" way to do it (with probably a little room for optimization :-)

#!/perl/bin/perl -w use strict; use Time::Local; my $endtime = "17:39:31"; my $starttime = "17:07:53"; my @end = split(":", $endtime); my @start = split(":", $starttime); my $end_epoch = timelocal(reverse(@end), 1,1,2007); my $start_epoch = timelocal(reverse(@start), 1,1,2007); my $elapsed = $end_epoch - $start_epoch; my $hours = int($elapsed / 3600); my $left = $elapsed - $hours * 3600; my $minutes = int($left / 60); my $seconds = $left % 60; printf "%02d:%02d:%02d\n", $hours, $minutes, $seconds; __OUTPUT__ 00:31:38

Where do you want *them* to go today?
  • Comment on Re: How to calculate the total time taken to complete the build operation
  • Download Code