CFLib.org – Common Function Library Project

DownLoadTime56k(fileSize)

Last updated November 1, 2002

author

William Steiner

Version: 1 | Requires: CF5 | 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:

<CFSET FileSizeExample = 260991> <!--- 255k --->

<cfoutput>
Estimated Download Time for 56k: #DownLoadTime56k(FileSizeExample)#
</cfoutput>

Parameters:

Name Description Required
fileSize File size in bytes. Yes

Full UDF Source:

/**
 * 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 ;
}
blog comments powered by Disqus

Search CFLib.org


Latest Additions

Kevin Cotton added
date2ExcelDate
May 5, 2016

Raymond Camden added
CapFirst
April 25, 2016

Chris Wigginton added
loremIpsum
January 18, 2016

Gary Stanton added
calculateArrival...
November 19, 2015

Sebastiaan Naafs - van Dijk added
getDaysInQuarter
November 13, 2015

Created by Raymond Camden / Design by Justin Johnson