[ABE.pm] time processing
fiedlert at gmail.com
Mon Nov 19 08:58:27 PST 2007
Im working on some programs to help me w/ running, producing graphs etc... I
need to convert time to seconds, do some simple math, then convert back to a
hh::mm::ss format. Im using DateTime::Precise to convert back, im just
curious and have been unable to find a way myself if there is a better way?
ie pure Perl. This just *seems* clunky.
use DateTime::Precise ;
my ( $hour, $min, $sec, undef ) = split/:/, $ARGV;
$hour = $hour * 3600;
$min = $min * 60;
my $seconds = $hour + $min + $sec;
my $distance = $ARGV;
print "seconds = $seconds\n";
my $t1 = DateTime::Precise->new($seconds / $distance);
my $pace = $t1->strftime('%T');
$pace =~ s/^00://;
print "Pace is $pace\n";
print "$0 time dist\n";
print " eg $0 01:54:18 13.1\n";
If you mess with a thing long enough, it'll break.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the ABE-pm