CFLib.org – Common Function Library Project

ConvertLegalHours(hourString)

Last updated July 3, 2002

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

 
Rated 1 time(s). Average Rating: 1.0

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:

view plain print about
<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:

view plain print about
<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>
blog comments powered by Disqus

Search CFLib.org


Latest Additions

Tayo Akinmade Tayo Akinmade added
arrayTrim
11 day(s) ago

Will Belden Will Belden added
longTime
17 day(s) ago

James Sleeman James Sleeman added
quickSort
27 day(s) ago

Ben Forta Ben Forta added
GetHostAddress
30 day(s) ago

Top Rated

Darwan Leonardo Sitepu EksporSQLData
Rated 5.0, 16 time(s)

Darwan Leonardo Sitepu backupDatabase
Rated 5.0, 13 time(s)

Barney Boisvert indentXml
Rated 5.0, 10 time(s)

Kevin Pepperman generateSsccAsn
Rated 5.0, 4 time(s)

Created by Raymond Camden / Design by Justin Johnson