Subject: | 24h overflow |
Date: | Fri, 04 Dec 2009 10:33:23 +0100 |
To: | bug-Time-Elapse [...] rt.cpan.org |
From: | Ireneusz Pluta <ipluta [...] wp.pl> |
Hello,
i often use Time::Elapse to log progress of processes which last for
more than 24 hours. But after 24 hours the %H part starts counting from
zero and what I see in my logs gets confusing. Therefore for my own
purposes I use my own 'Elapse' class, inherited from the Time::Elapse,
with the FETCH procedure modified appropriately, to show absolute number
of hours instead of modulo 24. Below is a patch which explains what I
did in my version. Please consider including it in the module in CPAN if
possible, or making it some other way.
Thanks
Ireneusz Pluta
--- Elapse.pm.orig Fri Dec 4 07:07:09 2009
+++ Elapse.pm Fri Dec 4 07:21:17 2009
@@ -49,7 +49,13 @@
print "Float = $float\n"
if $_DEBUG;
- my $int = strftime( "%H:%M:%S", localtime( $time -
$impl->{now}[0] ) );
+ my $interval = $time - $impl->{now}[0];
+ my $hh = int ($interval / 3600);
+ $interval -= $hh*3600;
+ my $mm = int ($interval / 60);
+ $interval -= $mm*60;
+ my $ss = $interval;
+ my $int = sprintf("%d:%02d:%02d", $hh, $mm, $ss);
print <<"EOF" if $_DEBUG;
# int = $int