CFLib.org – Common Function Library Project

DownLoadTime56k(fileSize)

Last updated November 1, 2002
Download UDF

author

William Steiner                                   William Steiner

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:

<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:

<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 Shawn Porter added
DeMoronize
3 hour(s) ago

Chris Carey Chris Carey added
readPropertiesFi...
1 day(s) ago

Randy Johnson Randy Johnson added
lastDayofWeek
3 day(s) ago

Frank Marion Frank Marion added
sitemapPing
7 day(s) ago

Top Rated

James Sleeman                                     QuickSort
Rated 5.0, 3 time(s)

Barney Boisvert indentXml
Rated 5.0, 3 time(s)

Nathan Dintenfass                                 queryColumnsToSt...
Rated 5.0, 3 time(s)

Kevin Pepperman generateSsccAsn
Rated 5.0, 3 time(s)

Created by Raymond Camden / Design by Justin Johnson