CFLib.org – Common Function Library Project

DownLoadTime56k(fileSize)

Last updated November 01, 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 ;
}

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

Created by Raymond Camden / Design by Justin Johnson