• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

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

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

<%
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人参与评论

请发表评论

全部评论

专题导读
上一篇:
如何计算ASP页面的载入时间?发布时间:2022-02-05
下一篇:
如何检测用户第一次访问我的网站并显示友好信息?发布时间:2022-02-05
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap