当前位置: 代码网 > it编程>编程语言>其他编程 > 如何计算下载一个文件需要多长时间?

如何计算下载一个文件需要多长时间?

2024年05月15日 其他编程 我要评论
<%function downloadtime(intfilesize, strmodemtype)dim timeinseconds, modemspeed, strdownloadtime,

<%
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 "56kbps"
  modemspeed = 7000
case "33.6kbps"
  modemspeed = 4200
case "28.8kbps"
  modemspeed = 3600
end select
timeinseconds = int(intfilesize / modemspeed)
'
准确地说,1年=365.25.
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
  strdownloadtime = strdownloadtime & intyears & "
" & appendstring & ", "
end if
if intweeks <> 0 then
  strdownloadtime = strdownloadtime & intweeks & "
" & appendstring & ", "
end if
if intdays <> 0 then
  strdownloadtime = strdownloadtime & intdays & "
" & appendstring & ", "
end if
if inthours <> 0 then
  strdownloadtime = strdownloadtime & inthours & "
小时" & appendstring & ", "
end if
if intminutes <> 0 then
  strdownloadtime = strdownloadtime & intminutes & "
" & appendstring
end if
if ((intyears = 0) and (intweeks = 0) and (intdays = 0) and (inthours = 0)) then
  if intminutes > 0 then
  strdownloadtime = strdownloadtime  & ", " & intseconds & "
" & appendstring
  else
  strdownloadtime = strdownloadtime & intseconds & "
" & appendstring
  end if
end if
downloadtime = strdownloadtime
end function
%>
<html>
<body>
撼雪喷云提示:您下载这个文件一共花费了<%=downloadtime(123456,cable)%>.
</body></html>

[1]

(0)

相关文章:

版权声明:本文内容由互联网用户贡献,该文观点仅代表作者本人。本站仅提供信息存储服务,不拥有所有权,不承担相关法律责任。 如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至 2386932994@qq.com 举报,一经查实将立刻删除。

发表评论

验证码:
Copyright © 2017-2025  代码网 保留所有权利. 粤ICP备2024248653号
站长QQ:2386932994 | 联系邮箱:2386932994@qq.com