[ABE.pm] time processing

Walt Mankowski waltman at pobox.com
Mon Nov 19 09:51:05 PST 2007


On Mon, Nov 19, 2007 at 12:31:36PM -0500, Ricardo SIGNES wrote:
> * Ted Fiedler <fiedlert at gmail.com> [2007-11-19T11:58:27]
> > 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.
> 
> Why Precise?  That seems like overkill.

My module Geo::Coordinates::DecimalDegrees is useful for things like
this:

#!/usr/bin/perl

use strict;
use warnings;
use Geo::Coordinates::DecimalDegrees;

my ( $hour, $min, $sec, undef ) = split/:/, $ARGV[0];
my $distance = $ARGV[1];

my $t = dms2decimal($hour, $min, $sec);
($hour, $min, $sec) = decimal2dms($t / $distance);
my $pace = sprintf "%02d:%02d", $min, $sec;

print  "Pace is $pace\n";

sub usage
{
    print "$0 time dist\n";
    print "  eg $0 01:54:18 13.1\n";
    exit 1;
}

I really need to repackage that module sometime.  It's useful for time
calculations as well as gps stuff, since hour/minute/second
calculations are the same as degree/minute/second calculations.  Also,
its name is way too long.

Oh well.

Walt


More information about the ABE-pm mailing list