DownLoadTime56k(fileSize)
Last updated November 1, 2002
Version: 1 | Requires: ColdFusion 5 | Library: UtilityLib
Description:
Returns estimated download time for a 56k modem given the file size. Returns a string in the format of "xx hours xx minutes xx seconds". File size should be in bytes.
Return Values:
Returns a string.
Example:
<cfoutput>
Estimated Download Time for 56k: #DownLoadTime56k(FileSizeExample)#
</cfoutput>
Parameters:
| Name | Description | Required |
|---|---|---|
| fileSize | File size in bytes. | Yes |
Full UDF Source:
<cfscript>
/**
* Returns estimated download time for a 56k modem given the file size.
*
* @param fileSize File size in bytes. (Required)
* @return Returns a string.
* @author William Steiner (williams@hkusa.com)
* @version 1, November 1, 2002
*/
function DownLoadTime56k(fileSize) {
var totalSeconds = (fileSize * 10) / 57600;
var tempstring = "";
var tempstring2 = "";
var hours = totalSeconds / 3600;
var minutes = totalSeconds / 60;
var seconds = totalSeconds MOD 60;
var hourText = "";
var minuteText = "";
// if over 60 minutes...get just minutes left from hours
if (minutes gte 60) minutes = minutes MOD 60;
if (hours gte 1) {
if (hours gt 2) hourText = " hours ";
else hourText = " hour ";
tempstring = Fix(hours) & hourText;
}
if (minutes gte 1) {
if (minutes gt 2) minuteText = " minutes ";
else minuteText = " minute ";
tempstring = tempstring & Fix(minutes) & minuteText;
}
if (seconds gt 0) tempstring = tempstring & seconds & " seconds";
return tempstring ;
}
</cfscript>
Search CFLib.org
Latest Additions
Shawn Porter added
DeMoronize
3 hour(s) ago
Chris Carey added
readPropertiesFi...
1 day(s) ago
Randy Johnson added
lastDayofWeek
3 day(s) ago
Frank Marion added
sitemapPing
7 day(s) ago
Top Rated
QuickSort
Rated 5.0, 3 time(s)
indentXml
Rated 5.0, 3 time(s)
queryColumnsToSt...
Rated 5.0, 3 time(s)
generateSsccAsn
Rated 5.0, 3 time(s)