S
simulant
I must have read about 150 different threads on how to perform date
arithmetic in Perl, but I am still not quite sure the best route to
take. When it comes to date arithmetic, it seems there are a lot of
frustrated programmers, from what I read in the posts!
Ok, here's the deal ... I have 4 dates:
$pstart = "12/08/06 14:00:00";
$pend = "12/08/06 14:00:02";
$qstart = "12/08/06 14:00:02";
$qend = "12/08/06 14:00:12";
I want to essentially do this ... pseudocode follows:
$total_time = ($pend - $pstart) + ($qend - $qstart);
I want $total_time to be in the format "hh:mm:ss"
I have been trying to use DateCalc from Date::Manip to help me out
here, but I'm stuck. I have the results of DateCalc, but how do I add
them together, or is there an overall better way to do this?:
$ptotal = DateCalc(ParseDate($pstart), ParseDate($pend)); # returns
"+0:0:0:0:0:0:2"
$qtotal = DateCalc(ParseDate($qstart), ParseDate($qend)); # returns
"+0:0:0:0:0:0:10"
So, in this case, I want to return the sum of the 2 above totals in
this format: "00:00:12"
arithmetic in Perl, but I am still not quite sure the best route to
take. When it comes to date arithmetic, it seems there are a lot of
frustrated programmers, from what I read in the posts!
Ok, here's the deal ... I have 4 dates:
$pstart = "12/08/06 14:00:00";
$pend = "12/08/06 14:00:02";
$qstart = "12/08/06 14:00:02";
$qend = "12/08/06 14:00:12";
I want to essentially do this ... pseudocode follows:
$total_time = ($pend - $pstart) + ($qend - $qstart);
I want $total_time to be in the format "hh:mm:ss"
I have been trying to use DateCalc from Date::Manip to help me out
here, but I'm stuck. I have the results of DateCalc, but how do I add
them together, or is there an overall better way to do this?:
$ptotal = DateCalc(ParseDate($pstart), ParseDate($pend)); # returns
"+0:0:0:0:0:0:2"
$qtotal = DateCalc(ParseDate($qstart), ParseDate($qend)); # returns
"+0:0:0:0:0:0:10"
So, in this case, I want to return the sum of the 2 above totals in
this format: "00:00:12"