Calculate the file download time

Source: Internet
Author: User
Calculate the file download time
  <%
Function downloadtime (intfilesize, strmodemtype)
Dim timeinseconds, modemspeed, strdownloadtime, appendstring
Dim intyears, intweeks, intdays
Dim inthours, intminutes, intseconds
Intyears = 0
Intweeks = 0
Intdays = 0
Inthours = 0
Intminutes = 0
Intseconds = 0
Strdownloadtime = ""
Select case strmodemtype
Case "Cable"
Modemspeed = 400000
Case "56 kbps"
Modemspeed = 7000
Case "33.6 Kbps"
Modemspeed = 4200
Case "28.8 Kbps"
Modemspeed = 3600
End select
Timeinseconds = int (intfilesize/modemspeed)
'Year maths added 1/4 of a day. 1 exact orbit of the sub is 365.25 days.
If (INT (timeinseconds/31471200) <> 0) Then intyears = int (timeinseconds/31449600)
If (INT (timeinseconds/604800) mod 52) <> 0) Then intweeks = int (timeinseconds/604800) mod 52
If (INT (timeinseconds/86400) mod 7) <> 0) Then intdays = int (timeinseconds/86400) mod 7
If timeinseconds >=3600 then inthours = int (timeinseconds/3600) mod 24
If timeinseconds> = 60 then intminutes = int (timeinseconds/60) mod 60
If timeinseconds> = 0 then intseconds = int (timeinseconds) mod 60
If intyears <> 0 then
If intyears = 1 then appendstring = "" else appendstring = "S"
Strdownloadtime = strdownloadtime & intyears & "year" & appendstring &","
End if
If intweeks <> 0 then
If intweeks = 1 then appendstring = "" else appendstring = "S"
Strdownloadtime = strdownloadtime & intweeks & "Week" & appendstring &","
End if
If intdays <> 0 then
If intdays = 1 then appendstring = "" else appendstring = "S"
Strdownloadtime = strdownloadtime & intdays & "day" & appendstring &","
End if
If inthours <> 0 then
If inthours = 1 then appendstring = "" else appendstring = "S"
Strdownloadtime = strdownloadtime & inthours & "Hour" & appendstring &","
End if
If intminutes <> 0 then
If intminutes = 1 then appendstring = "" else appendstring = "S"
Strdownloadtime = strdownloadtime & intminutes & "Minute" & appendstring
End if
If (intyears = 0) and (intweeks = 0) and (intdays = 0) and (inthours = 0) then
If intseconds = 1 then appendstring = "" else appendstring = "S"
If intminutes> 0 then
Strdownloadtime = strdownloadtime & "," & intseconds & "second" & appendstring
Else
Strdownloadtime = strdownloadtime & intseconds & "second" & appendstring
End if
End if
Downloadtime = strdownloadtime
End Function
%>
<HTML>
<Body>
It is going to take about
<% = Downloadtime (123456, cable) %> to download this file.
</Body>
</Html>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.