CFLib.org – Common Function Library Project

ConvertLegalHours(hourString)

Last updated July 3, 2002

Version: 1 | Requires: ColdFusion 5 | Library: DateLib

Description:
Converts h:mm:ss or h:mm strings to hours rounded to tenths, used in my case for legal time billing.

Return Values:
Returns a string.

Example:

<cfset HoursInTenths = ConvertHours("6:33:06")>
<cfoutput>#Variables.HoursInTenths#</cfoutput>

Parameters:

Name Description Required
hourString A string containing the number of hours, minutes, and seconds in the format: H:MM:SS. Yes

Full UDF Source:

<cfscript>
/**
* Function that returns legal billing time from standard time format.
*
* @param hourString      A string containing the number of hours, minutes, and seconds in the format: H:MM:SS. (Required)
* @return Returns a string.
* @author Joe (jcraven@akingump.com)
* @version 1, July 3, 2002
*/

function ConvertHours(HourString) {
    var HourWords = "";
    var MinuteVal = Round(val(listGetAt(HourString,2,":"))/6);
    var HourVal = listFirst(hourString,":");
    
    if(len(HourVal) is 1) {
        if(HourVal is "0") HourWords = '0.';
        else HourWords = HourVal & '.';
    } else HourWords = HourVal & '.';
    
    HourWords = HourWords & MinuteVal;
    return HourWords;
}
</cfscript>

Search CFLib.org


Latest Additions

Jose Diaz-Salcedo Jose Diaz-Salcedo added
cfRssFeed
3 day(s) ago

Raymond Compton Raymond Compton added
structBlend
23 day(s) ago

Duncan Duncan added
IsZIPUK
23 day(s) ago

Todd Sharp Todd Sharp added
getTagContentAll
29 day(s) ago

Gerald Guido Gerald Guido added
ListReturnDuplicat...
1 month(s) ago

Created by Raymond Camden / Design by Justin Johnson