高分请教,日历的算法!!!!

F9 2003-01-17 01:37:25
加精
高分请教,日历的算法!!!!
最好详细一点
...全文
41 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
huaben 2003-07-02
  • 打赏
  • 举报
回复
怎么用?
fbj007 2003-01-17
  • 打赏
  • 举报
回复
以前的收藏,看对你是否有用?
<%'获取正确的日期
Function YmdList(yi,mi,di)
Dim y,m,d
'年
if yi="" or isnumeric(yi)=false then
y=year(now())
else
y=yi
end if

'月
if mi="" or isnumeric(mi)=false then
m=Month(now())
else
m=mi
end if
if m>13 then m=13
if m<1 then m=1

'日
if di="" or isnumeric(di)=false then
d=day(now())
else
d=di
end if
if m=2 and d>28 then
if y mod 4=0 then
if y mod 100=0 then
if y mod 1000=0 then
d=29
else
d=28
end if
else
d=29
end if
else
d=28
end if
end if
if (m=4 or m=6 or m=9 or m=11) and d>30 then d=30
if d<1 then d=1
YmdList=cstr(y)&"-"&cstr(m)&"-"&cstr(d)
End Function
%>

<%'获取正确的日期时间
Function YmdHms(yi,mi,di,hi,msi,si)
dim h,ms,s

'时
if hi="" or isnumeric(hi)=false then
h=0
else
h=hi
end if
if h<0 then h=0
if h>=24 then h=23

'分
if msi="" or isnumeric(msi)=false then
ms=0
else
ms=msi
end if
if ms<0 then ms=0
if ms>=60 then ms=59

'秒
if si="" or isnumeric(si)=false then
s=0
else
s=si
end if
if s<0 then s=0
if s>=60 then s=59
YmdHms=YmdList(yi,mi,di)&" "&h&":"&ms&":"&s
End Function%>


<%'每月的天数
Function MonthDays(Yeari,Monthi)
Dim Days
Days=0
if Monthi=2 then
if Yeari mod 4=0 then
if Yeari mod 100=0 then
if Yeari mod 1000=0 then
Days=29
else
Days=28
end if
else
Days=29
end if
else
Days=28
end if
else
if Monthi=4 or Monthi=6 or Monthi=9 or Monthi=11 then
Days=30
else
Days=31
end if
end if
MonthDays=Days
End Function%>

<%'每天是星期几
Function DayWeek(Yeari,Monthi,Dayi)
Dim Days
Days=0
Dim yi,mi
'年
For yi=2001 to Yeari-1
if yi mod 4=0 then
if yi mod 100=0 then
if yi mod 1000=0 then
Days=Days+366
else
Days=Days+365
end if
else
Days=Days+366
end if
else
Days=Days+365
end if
Next
'月
For mi=1 to Monthi-1
Days=Days+MonthDays(Yeari,mi)
Next
Days=Days+Dayi
DayWeek=Days mod 7
End Function%>

<%'星期的中文表示方法
Function WeekName(wi)
Select case wi
case 0
WeekName="日"
case 1
WeekName="一"
case 2
WeekName="二"
case 3
WeekName="三"
case 4
WeekName="四"
case 5
WeekName="五"
case 6
WeekName="六"
End Select
WeekName="星期"&WeekName
End Function


function FirstDayOfWeek (nYear, nIndex)
dim dt, n
dt = dateserial(nYear, 1,1)
n = weekday(dt)
if n > 2 then
dt = dateadd("d", 7-n+2 , dt)
else
dt = dateadd("d", 2-n , dt)
end if

if nIndex > 1 then
dt = dateadd("d", 7*(nIndex-1) , dt)
end if
FirstDayOfWeek = dt
end function%>

28,391

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧