CleanCode Perl Libraries
Multi-Lingual Library Maintainability
available: Perl available: Java not available: JavaScript available: Certified
Class
not available: Testable
Class
not available: Standalone
Mode
not available: Diagnostic
Enabled

NAME

Time::SimpleFormat - Provides calendar-related auxiliary functions.

SYNOPSIS

        use Time::SimpleFormat;
        print minutesToHHMM($minuteCount);
        if (HHMMtoMinutes($val) > 60) ...
        print secondsToMMSS($secondCount);
        print secondsToClock($secondCount);
        $secs = MMSStoSeconds($timeString);
        print hourstoHHMM($hourCount);
        if (HHMMtoHours($val) > 24) ...
        print elapsed($startTime, $endTime);
        print formatDateTime(time());

REQUIRES

Perl5.005, POSIX

EXPORTS

Default: none

Optional: minutesToHHMM, HHMMtoMinutes, secondsToMMSS, MMSStoSeconds, hoursToHHMM, HHMMtoHours, secondsToClock, formatDateTime, elapsed

DESCRIPTION

This is a collection of functions used to convert times from displayable format to numbers and back again.

FUNCTIONS

minutesToHHMM

minutesToHHMM(minutes)

Converts minutes to canonical HH:MM format.

Parameters:

minutes - integer representing a number of minutes

Returns:

string displaying hours and minutes in the format HH:MM

HHMMtoMinutes

HHMMtoMinutes(time)

Converts canonical HH:MM to minutes.

Parameters:

time - string in MM:SS format

Returns:

integer number of minutes

secondsToMMSS

secondsToMMSS(seconds)

Converts seconds to canonical MM:SS format.

Parameters:

seconds - integer representing a number of minutes

Returns:

string displaying minutes and seconds in the format MM:SS

MMSStoSeconds

MMSStoSeconds(time)

Converts canonical MM:SS to seconds.

Parameters:

time - string in MM:SS format

Returns:

integer number of seconds

hoursToHHMM

hoursToHHMM(hours)

Converts hours to canonical HH:MM format.

Parameters:

hours - float representing a number of hours

Returns:

string displaying hours and minutes in the format HH:MM

HHMMtoHours

HHMMtoHours(time)

Converts canonical HH:MM to hours.

Parameters:

time - string in HH:MM format

Returns:

number of seconds as a floating point number

secondsToClock

secondsToClock(seconds)

Converts seconds to canonical HH:MM:SS format.

Parameters:

seconds - integer representing a number of minutes

Returns:

8-character string displaying hours, minutes, and seconds in the format HH:MM:SS

formatDateTime

formatDateTime(startTime, endTime)

Converts standard time value to a canonical output string in the format 'YYYY-MM-DD HH:MM:SS".

Parameters:

time - integer representing a time in seconds since epoch

Returns:

string in the format 'YYYY-MM-DD HH:MM:SS"

elapsed

elapsed(startTime, endTime)

Calculates elapsed interval between the start and end times, and provides a displayable string. The result is the concatenation of the elapsed clock time (HH:MM:SS) and the number of closest units (e.g. 75 seconds, 5.32 minutes, or 12.45 hours).

Parameters:

startTime - integer representing a start time in seconds

endTime - integer representing an end time in seconds

Returns:

elapsed string in the format "HH:MM:SS (units)" where units is either "seconds", "minutes", or "hours".

BUGS

None

AUTHOR

Michael Sorens

VERSION

$Revision: 8 $ $Date: 2006-12-19 21:13:43 -0800 (Tue, 19 Dec 2006) $

SINCE

CleanCode 0.9

SEE ALSO

Date::Calc

POD ERRORS

Hey! The above document had some coding errors, which are explained below:

Around line 359:

=back doesn't take any parameters, but you said =back -- end of FUNCTION section


CleanCode Perl Libraries Copyright © 2001-2013 Michael Sorens - Revised 2013.06.30 Get CleanCode at SourceForge.net. Fast, secure and Free Open Source software downloads