ConvertLegalHours(hourString)
Last updated July 03, 2002
Version: 1 | Requires: CF5 | 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:
/**
* 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;
}
Search CFLib.org
Latest Additions
Raymond Camden added
QueryDeleteRows
November 04, 2017
Leigh added
nullPad
May 11, 2016
Raymond Camden added
stripHTML
May 10, 2016
Kevin Cotton added
date2ExcelDate
May 05, 2016
Raymond Camden added
CapFirst
April 25, 2016