Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: How to calculate the total time taken to complete the build operation

by thezip (Vicar)
on May 09, 2007 at 15:34 UTC ( [id://614419]=note: print w/replies, xml ) Need Help??


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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://614419]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (8)
As of 2024-04-24 12:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found