Chris Cobb
and 1 contributors

NAME

PTools::Time::Elapsed - Create formatted string with elapsed time

VERSION

This document describes version 0.05, released Dec, 2003.

SYNOPSIS

         use PTools::Time::Elapsed;
         $et  = new PTools::Time::Elapsed;

         $str = $et->convert( $elapsed_seconds );
   or    $str = $et->convert( $starttime, $endtime );

         $str = $et->cvt_secs_print( $elapsed_seconds );
   or    $str = $et->cvt_secs_print( $starttime, $endtime );
 
         $str = $et->days( $elapsed_seconds );
   or    $str = $et->days( $starttime, $endtime );

         $str = $et->hours( $elapsed_seconds );
   or    $str = $et->hours( $starttime, $endtime );

         $str = $et->granular( $elapsed_seconds );
   or    $str = $et->granular( $starttime, $endtime );

         (@ary) = $et->convertArgs( $elapsed_seconds );
   or    (@ary) = $et->convertArgs( $starttime, $endtime );

DESCRIPTION

This module is based on the cvt_secs_print() subroutine by Douglas B. Robinson.

Constructor

new

A constructor method is provided for convenience. All methods work equally well as class or object methods as shown below.

         $et  = new PTools::Time::Elapsed;

Methods

convert ( { ElapsedSeconds | StartTime, EndTime } )

The convert method returns a human readable time string from a given number of seconds.

         $str = $et->convert( $elapsed_seconds );
   or    $str = $et->convert( $starttime, $endtime );

The convert method can also be invoked using the original subroutine name.

         $str = $et->cvt_secs_print( $elapsed_seconds );
   or    $str = $et->cvt_secs_print( $starttime, $endtime );

Note: All methods work as both object methods (shown above) and as class methods (shown here).

         $str = PTools::Time::Elapsed->convert( $elapsed_seconds );
   or    $str = PTools::Time::Elapsed->convert( $starttime, $endtime );

For all of the above, $str result might equal "1 hour, 51 seconds", for example.

days ( { ElapsedSeconds | StartTime, EndTime } )

The days method exists to return the result in days with any hours represented as a decimal value.

         $str = $et->days( $elapsed_seconds );
   or    $str = $et->days( $starttime, $endtime );

Where $str result might equal "0.04 days", for example.

hours ( { ElapsedSeconds | StartTime, EndTime } )

The hours method exists to return the result in hours with any minutes represented as a decimal value.

         $str = $et->hours( $elapsed_seconds );
   or    $str = $et->hours( $starttime, $endtime );

Where $str result might equal "1.00 hours", for example.

granular ( { ElapsedSeconds | StartTime, EndTime } )

The granular method exists to provide for a more "granular" result (in terms of the "most significant" element).

         $str = $et->granular( $elapsed_seconds );
   or    $str = $et->granular( $starttime, $endtime );

Where $str result might equal "1.00 hrs", for example.

convertArgs ( { ElapsedSeconds | StartTime, EndTime } )

The convertArgs method provides the raw values for each of the elements.

         (@ary) = $et->convertArgs( $elapsed_seconds );
   or    (@ary) = $et->convertArgs( $starttime, $endtime );

Where @ary params = ($yrs,$days,$hrs,$mins,$secs) and @ary result might equal (0,0,1,0,51) for example.

INHERITANCE

No classes currently inherit from this class.

SEE ALSO

AUTHOR

Chris Cobb [no dot spam at ccobb dot net]

COPYRIGHT

Copyright (c) 2002-2007 by Chris Cobb. All rights reserved. This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself.