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.
<br><br>#!/usr/bin/perl<br><br>use strict;<br>use warnings;<br>use DateTime::Precise ;<br><br>my ( $hour, $min, $sec, undef ) = split/:/, $ARGV[0];<br><br>$hour = $hour * 3600;<br>$min = $min * 60;<br><br>my $seconds = $hour + $min + $sec;
<br><br>my $distance = $ARGV[1];<br><br>print "seconds = $seconds\n";<br><br>my $t1 = DateTime::Precise->new($seconds / $distance);<br><br>my $pace = $t1->strftime('%T');<br><br>$pace =~ s/^00://;<br>
<br>print "Pace is $pace\n";<br><br>sub usage<br>{<br> print "$0 time dist\n";<br> print " eg $0 01:54:18 13.1\n";<br> exit 1;<br>}<br clear="all"><br>Ted<br>-- <br>If you mess with a thing long enough, it'll break.
<br> -- Schmidt