Calculate Time To Download Over Specified Connecti

Results 1 to 3 of 3

Thread: Calculate Time To Download Over Specified Connecti

  1. #1
    Rob Black Guest

    Default Calculate Time To Download Over Specified Connecti

    Hi<BR><BR>For my download page, i want to let the visitors know roughly how long it will take to download a file. (E.G 12.5MB (approx. 1h 29m over 33.6 connection))<BR><BR>I was playing around last night and came up with this:<BR><BR>Function TheFS(FSinK, Modem)<BR> Dim TheTime<BR> TheTime = FSinK * 1024 / Modem<BR> FormattedTime = TimeSerial(00,00,TheTime)<BR> TheFS = FormatDateTime(FormattedTime,4)<BR> End Function<BR><BR>Response.Write TheFS(Request.QueryString("Size"),Request.QueryStr ing("ModemKbps"))<BR><BR>This kinda works, if finding out the number of bytes is FileKBSize * 1024, but that&#039s not my main problem, i can find out about filesizes anytime....The main problem is formatting a bunch of seconds into days, hours, minutes and seconds.<BR><BR>In the function above, if i feed it 665600 (about 650MB) it overflows, because TimeSerial isn&#039t for diaplaying a unit of time, but actual times themselves. So when it says it&#039ll take 01:25:30 to download a file, it&#039s actually saying it&#039s 25 past 1 in the morning :-) I have a funny feeling that i&#039l need JScript to do what i need, seeing as it seems to have more time/math stuff.<BR><BR>If anyone can help (Perhaps the dev teem for MS Windows Update may be able to help :-) ) I&#039d be most intrested in what you have to say.

  2. #2
    Join Date
    Dec 1969

    Default RE: Calculate Time To Download Over Specified Conn

    Hey Rob.<BR><BR>Geez, you&#039re really making it WAY too difficult for yourself. Just use this function to turn the seconds you have into hours, minutes and seconds:<BR><BR>&#060;%<BR> Function FormatSeconds(Seconds)<BR> Hours = Int(Seconds/3600)<BR> Minutes = Int((Seconds-Hours*3600)/60)<BR> Seconds = Seconds-(Hours*3600+Minutes*60)<BR> If Len(Minutes) = 1 Then<BR> Minutes = "0" & Minutes<BR> End If<BR> If Len(Seconds) = 1 Then<BR> Seconds = "0" & Seconds<BR> End If<BR> FormatSeconds = Hours & ":" & Minutes & ":" & Seconds<BR> End Function<BR>%&#062;<BR><BR>And you call it like this:<BR><BR>&#060;%<BR> Response.Write FormatSeconds(7199)<BR>%&#062;<BR><BR>Which returns:<BR>1:59:59<BR><BR>Just a side note... If I wanted to download anything, I would rather see it like this:<BR><BR>The download is going to take approximately 1 hour, 59 minutes and 59 seconds on a 33.6 kbps modem, but maybe you have limited space in a table, or whatever. Or maybe you just like it better your way. Either way, not my decision. :)<BR><BR>Take care,<BR>Lasse.<BR>( )<BR>

  3. #3
    Rob Guest

    Default My Hero!

    Thank you!!<BR><BR>Don&#039t you hate it when the answer to your problems is the most simple!<BR><BR>Thank&#039s again, and i&#039ll take on board your tip on formatting the download time too :-)<BR><BR>Rob.<BR>( )

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts