CFLib.org – Common Function Library Project

DownLoadTime56k(fileSize)

Last updated November 1, 2002

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

 
Rated 0 time(s). Average Rating: 0

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:

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

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

Search CFLib.org


Latest Additions

Dave Anderson Dave Anderson added
iniToStruct
20 day(s) ago

Dave Anderson Dave Anderson added
deDupeArray
20 day(s) ago

Richard Richard added
dice
22 day(s) ago

Isaac Dealey Isaac Dealey added
getRelative
a while ago

Top Rated

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

Barney Boisvert indentXml
Rated 5.0, 10 time(s)

Kevin Pepperman generateSsccAsn
Rated 5.0, 4 time(s)

Raymond Camden highlightAndCrop
Rated 5.0, 4 time(s)

Created by Raymond Camden / Design by Justin Johnson