欢迎光临
我们一直在努力

酷月历(公、农历)-ASP教程,ASP应用

建站超值云服务器,限时71元/月

将以下文件保存为 calender.asp,调用时 用<include file="calender.asp">

<%

原创:jaron,转载请说明出处

dim m_minyear

dim m_maxyear

dim nonglidayname

dim nonglimonthname

m_minyear= 1950

m_maxyear= 2050

dim calendardata(99,2)

nonglidayname= array("初一","初二","初三","初四","初五","初六","初七","初八","初九","初十","十一","十二","十三","十四","十五","十六","十七","十八","十九","廿","廿一","廿二","廿三","廿四","廿五","廿六","廿七","廿八","廿九","三十")

nonglimonthname = array("正","二","三","四","五","六","七","八","九","十","十一","十二")

calendardata(0,0)=&h2f

calendardata(0,1)=&h6c

calendardata(0,2)=&ha0

calendardata(1,0)=&h24

calendardata(1,1)=&hb5

calendardata(1,2)=&h50

calendardata(2,0)=&hda

calendardata(2,1)=&h53

calendardata(2,2)=&h55

calendardata(3,0)=&h2c

calendardata(3,1)=&h4d

calendardata(3,2)=&ha0

calendardata(4,0)=&h21

calendardata(4,1)=&ha5

calendardata(4,2)=&hb0

calendardata(5,0)=&h57

calendardata(5,1)=&h45

calendardata(5,2)=&h73

calendardata(6,0)=&haa

calendardata(6,1)=&h52

calendardata(6,2)=&hb0

calendardata(7,0)=&h1e

calendardata(7,1)=&ha9

calendardata(7,2)=&ha8

calendardata(8,0)=&h30

calendardata(8,1)=&he9

calendardata(8,2)=&h50

calendardata(9,0)=&h26

calendardata(9,1)=&h6a

calendardata(9,2)=&ha0

calendardata(10,0)=&h9b

calendardata(10,1)=&hae

calendardata(10,2)=&ha6

calendardata(11,0)=&h2d

calendardata(11,1)=&hab

calendardata(11,2)=&h50

calendardata(12,0)=&h23

calendardata(12,1)=&h4b

calendardata(12,2)=&h60

calendardata(13,0)=&h18

calendardata(13,1)=&haa

calendardata(13,2)=&he4

calendardata(14,0)=&hab

calendardata(14,1)=&ha5

calendardata(14,2)=&h70

calendardata(15,0)=&h20

calendardata(15,1)=&h52

calendardata(15,2)=&h60

calendardata(16,0)=&h14

calendardata(16,1)=&hf2

calendardata(16,2)=&h63

calendardata(17,0)=&h27

calendardata(17,1)=&hd9

calendardata(17,2)=&h50

calendardata(18,0)=&h9d

calendardata(18,1)=&h5b

calendardata(18,2)=&h57

calendardata(19,0)=&h2f

calendardata(19,1)=&h56

calendardata(19,2)=&ha0

calendardata(20,0)=&h24

calendardata(20,1)=&h96

calendardata(20,2)=&hd0

calendardata(21,0)=&h1a

calendardata(21,1)=&h4d

calendardata(21,2)=&hd5

calendardata(22,0)=&had

calendardata(22,1)=&h4a

calendardata(22,2)=&hd0

calendardata(23,0)=&h21

calendardata(23,1)=&ha4

calendardata(23,2)=&hd0

calendardata(24,0)=&h16

calendardata(24,1)=&hd4

calendardata(24,2)=&hd4

calendardata(25,0)=&h29

calendardata(25,1)=&hd2

calendardata(25,2)=&h50

calendardata(26,0)=&h9e

calendardata(26,1)=&hd5

calendardata(26,2)=&h58

calendardata(27,0)=&h30

calendardata(27,1)=&hb5

calendardata(27,2)=&h40

calendardata(28,0)=&h25

calendardata(28,1)=&hb6

calendardata(28,2)=&ha0

calendardata(29,0)=&h5b

calendardata(29,1)=&h95

calendardata(29,2)=&ha6

calendardata(30,0)=&hae

calendardata(30,1)=&h95

calendardata(30,2)=&hb0

calendardata(31,0)=&h23

calendardata(31,1)=&h49

calendardata(31,2)=&hb0

calendardata(32,0)=&h18

calendardata(32,1)=&ha9

calendardata(32,2)=&h74

calendardata(33,0)=&h2b

calendardata(33,1)=&ha4

calendardata(33,2)=&hb0

calendardata(34,0)=&ha0

calendardata(34,1)=&hb2

calendardata(34,2)=&h7a

calendardata(35,0)=&h32

calendardata(35,1)=&h6a

calendardata(35,2)=&h50

calendardata(36,0)=&h27

calendardata(36,1)=&h6d

calendardata(36,2)=&h40

calendardata(37,0)=&h1c

calendardata(37,1)=&haf

calendardata(37,2)=&h46

calendardata(38,0)=&haf

calendardata(38,1)=&hab

calendardata(38,2)=&h60

calendardata(39,0)=&h24

calendardata(39,1)=&h95

calendardata(39,2)=&h70

calendardata(40,0)=&h1a

calendardata(40,1)=&h4a

calendardata(40,2)=&hf5

calendardata(41,0)=&h2d

calendardata(41,1)=&h49

calendardata(41,2)=&h70

calendardata(42,0)=&ha2

calendardata(42,1)=&h64

calendardata(42,2)=&hb0

calendardata(43,0)=&h16

calendardata(43,1)=&h74

calendardata(43,2)=&ha3

calendardata(44,0)=&h28

calendardata(44,1)=&hea

calendardata(44,2)=&h50

calendardata(45,0)=&h1e

calendardata(45,1)=&h6b

calendardata(45,2)=&h58

calendardata(46,0)=&hb1

calendardata(46,1)=&h5a

calendardata(46,2)=&hc0

calendardata(47,0)=&h25

calendardata(47,1)=&hab

calendardata(47,2)=&h60

calendardata(48,0)=&h1b

calendardata(48,1)=&h96

calendardata(48,2)=&hd5

calendardata(49,0)=&h2e

calendardata(49,1)=&h92

calendardata(49,2)=&he0

calendardata(50,0)=&ha3

calendardata(50,1)=&hc9

calendardata(50,2)=&h60

calendardata(51,0)=&h17

calendardata(51,1)=&hd9

calendardata(51,2)=&h54

calendardata(52,0)=&h2a

calendardata(52,1)=&hd4

calendardata(52,2)=&ha0

calendardata(53,0)=&h1f

calendardata(53,1)=&hda

calendardata(53,2)=&h50

calendardata(54,0)=&h95

calendardata(54,1)=&h75

calendardata(54,2)=&h52

calendardata(55,0)=&h27

calendardata(55,1)=&h56

calendardata(55,2)=&ha0

calendardata(56,0)=&h1c

calendardata(56,1)=&hab

calendardata(56,2)=&hb7

calendardata(57,0)=&h30

calendardata(57,1)=&h25

calendardata(57,2)=&hd0

calendardata(58,0)=&ha5

calendardata(58,1)=&h92

calendardata(58,2)=&hd0

calendardata(59,0)=&h19

calendardata(59,1)=&hca

calendardata(59,2)=&hb5

calendardata(60,0)=&h2c

calendardata(60,1)=&ha9

calendardata(60,2)=&h50

calendardata(61,0)=&h21

calendardata(61,1)=&hb4

calendardata(61,2)=&ha0

calendardata(62,0)=&h96

calendardata(62,1)=&hba

calendardata(62,2)=&ha4

calendardata(63,0)=&h28

calendardata(63,1)=&had

calendardata(63,2)=&h50

calendardata(64,0)=&h1e

calendardata(64,1)=&h55

calendardata(64,2)=&hd9

calendardata(65,0)=&h31

calendardata(65,1)=&h4b

calendardata(65,2)=&ha0

calendardata(66,0)=&ha6

calendardata(66,1)=&ha5

calendardata(66,2)=&hb0

calendardata(67,0)=&h5b

calendardata(67,1)=&h51

calendardata(67,2)=&h76

calendardata(68,0)=&h2e

calendardata(68,1)=&h52

calendardata(68,2)=&hb0

calendardata(69,0)=&h23

calendardata(69,1)=&ha9

calendardata(69,2)=&h30

calendardata(70,0)=&h98

calendardata(70,1)=&h79

calendardata(70,2)=&h54

calendardata(71,0)=&h2a

calendardata(71,1)=&h6a

calendardata(71,2)=&ha0

calendardata(72,0)=&h1f

calendardata(72,1)=&had

calendardata(72,2)=&h50

calendardata(73,0)=&h15

calendardata(73,1)=&h5b

calendardata(73,2)=&h52

calendardata(74,0)=&ha8

calendardata(74,1)=&h4b

calendardata(74,2)=&h60

calendardata(75,0)=&h1c

calendardata(75,1)=&ha6

calendardata(75,2)=&he6

calendardata(76,0)=&h2f

calendardata(76,1)=&ha4

calendardata(76,2)=&he0

calendardata(77,0)=&h24

calendardata(77,1)=&hd2

calendardata(77,2)=&h60

calendardata(78,0)=&h99

calendardata(78,1)=&hea

calendardata(78,2)=&h65

calendardata(79,0)=&h2b

calendardata(79,1)=&hd5

calendardata(79,2)=&h30

calendardata(80,0)=&h21

calendardata(80,1)=&h5a

calendardata(80,2)=&ha0

calendardata(81,0)=&h16

calendardata(81,1)=&h76

calendardata(81,2)=&ha3

calendardata(82,0)=&ha9

calendardata(82,1)=&h96

calendardata(82,2)=&hd0

calendardata(83,0)=&h1e

calendardata(83,1)=&h4a

calendardata(83,2)=&hfb

calendardata(84,0)=&h31

calendardata(84,1)=&h4a

calendardata(84,2)=&hd0

calendardata(85,0)=&h26

calendardata(85,1)=&ha4

calendardata(85,2)=&hd0

calendardata(86,0)=&hdb

calendardata(86,1)=&hd0

calendardata(86,2)=&hb6

calendardata(87,0)=&h2d

calendardata(87,1)=&hd2

calendardata(87,2)=&h50

calendardata(88,0)=&h22

calendardata(88,1)=&hd5

calendardata(88,2)=&h20

calendardata(89,0)=&h17

calendardata(89,1)=&hdd

calendardata(89,2)=&h45

calendardata(90,0)=&haa

calendardata(90,1)=&hb5

calendardata(90,2)=&ha0

calendardata(91,0)=&h1f

calendardata(91,1)=&h56

calendardata(91,2)=&hd0

calendardata(92,0)=&h15

calendardata(92,1)=&h55

calendardata(92,2)=&hb2

calendardata(93,0)=&h28

calendardata(93,1)=&h49

calendardata(93,2)=&hb0

calendardata(94,0)=&h9d

calendardata(94,1)=&ha5

calendardata(94,2)=&h77

calendardata(95,0)=&h2f

calendardata(95,1)=&ha4

calendardata(95,2)=&hb0

calendardata(96,0)=&h24

calendardata(96,1)=&haa

calendardata(96,2)=&h50

calendardata(97,0)=&h59

calendardata(97,1)=&hb2

calendardata(97,2)=&h55

calendardata(98,0)=&hac

calendardata(98,1)=&h6d

calendardata(98,2)=&h20

calendardata(99,0)=&h20

calendardata(99,1)=&had

calendardata(99,2)=&ha0

on error resume next

function gongdataisvalid(m_date)

if not isdate(m_date) then

gongdataisvalid = false

exit function

else

if year(m_date) >1950 and year(m_date) < 2050 then

gongdataisvalid = true

exit function

else

if year(m_date)=1950 then

if month(m_date)>2 then

gongdataisvalid = true

exit function

else

if month(m_date)=2 then

if day(m_date) > 16 then

gongdataisvalid = true

exit function

end if

end if

end if

end if

end if

end if

gongdataisvalid = false

end function

function nongdataisvalid(m_date)

if year(m_date) > 1949 and year(m_date) < 2049 then

nongdataisvalid = true

exit function

else

if year(m_date)=2049 then

if month(m_date.month) < 12 then

nongdataisvalid = true

exit function

else

if month(m_date)=12 then

if day(m_date) < 8 then

nongdataisvalid = true

exit function

end if

end if

end if

end if

end if

nongdataisvalid = false

end function

function converttogongli(m_nongli)

dim days

dim years

dim alldays

dim result

days = daysfromspringday(m_nongli)

days = days + getdaysfromstart(year(m_nongli))

years = year(m_nongli)

alldays = getgongyeardays(years)

if days > alldays then

days = days – alldays

years = years + 1

end if

result = calgongdate(years,days)

converttogongli = result

end function

function converttonongli(m_gongli)

dim days

dim years

dim alldays

dim result

days = daysfromnewyear(m_gongli)

alldays = getdaysfromstart(year(m_gongli))

years = year(m_gongli)

if days <= alldays then

years = years – 1

days = days + getgongyeardays(years)

end if

days = days – getdaysfromstart(years)

result = calnongdate(years,days)

converttonongli = result

end function

function getdateafterdays(m_first,m_days)

dim m_firstdays

m_firstdays = daysfromnewyear(m_first) + m_days

getdateafterdays = calgongdate(year(m_first),m_firstdays)

end function

function calgongdate(years,days)

dim resultday,resultyear,resultmonth

dim caldays

caldays = 0

resultyear = years

for i=1 to 13 – 1

caldays =caldays + getgongmonthdays(years,i)

if caldays>=days then

caldays = caldays – getgongmonthdays(year,i)

resultmonth = i

resultday=days-caldays

exit for

end if

next

calgongdate=resultyear & "-" & resultmonth & "-" & resultday

end function

function calnongdate(years,days)

dim resultday,resultyear,resultmonth

dim caldays

caldays = 0

resultyear = years

isrunyue = false

for i=1 to 12

caldays = caldays + getnotrunnongmonthdays(years,i)

if caldays>=days then

caldays = caldays – getnotrunnongmonthdays(years,i)

resultmonth = i

resultday = days – caldays

isrunyue = false

exit for

else

if getnongrunyue(years) = i then

caldays = caldays + getnongrunyuedays(years)

if caldays>=days then

caldays = caldays – getnongrunyuedays(years)

resultmonth = i

resultday = days – caldays

isrunyue = true

exit for

end if

end if

end if

next

calnongdate=resultyear & "-" & resultmonth & "-" & resultday

end function

function getgongmonthdays(years,months)

getgongmonthdays = 30

if months = 2 then

if yearisrunnian(years) then

getgongmonthdays = 29

else

getgongmonthdays = 28

end if

else

if gongmonthislarge(months) then

getgongmonthdays = 31

else

getgongmonthdays = 30

end if

end if

end function

function getnonglidayname(mdays)

dim i,j

i = instr(mdays,"-")

j = instr(i+1,mdays,"-")

getnonglidayname = right(mdays,len(mdays) – j)

getnonglidayname = nonglidayname(int(getnonglidayname) – 1)

end function

function getnonglimonthname(mdays)

dim i,j

i = instr(mdays,"-")

j = instr(i+1,mdays,"-")

getnonglimonthname = mid(mdays,i+1,j-i-1)

getnonglimonthname = nonglimonthname(int(getnonglimonthname) – 1)

end function

function getnotrunnongmonthdays(years,months)

if nongmonthislarge(years,months) then

getnotrunnongmonthdays = 30

else

getnotrunnongmonthdays = 29

end if

end function

function getnongmonthdays(years,months,m_run)

dim days

days = 0

if m_run then

days = getnongrunyuedays(years)

else

days = getnotrunnongmonthdays(years,months)

end if

getnongmonthdays = days

end function

function getgongyeardays(years)

if yearisrunnian(years) then

getgongyeardays = 366

else

getgongyeardays = 365

end if

end function

function getnongyeardays(years)

dim days

days = 0

for i=1 to 12

days =days + getnongmonthdays(years,i,false)

next

days =days + getnongrunyuedays(years)

getnongyeardays = days

end function

function getnongrunyuedays(years)

if getnongrunyue(years) =0 then

getnongrunyuedays = 0

exit function

end if

if runyueislarge(years) then

getnongrunyuedays = 30

else

getnongrunyuedays = 29

end if

end function

function daysfromnewyear(m_day)

dim days

days = 0

for i=1 to month(m_day) – 1

days = days + getgongmonthdays(year(m_day),i)

next

days = days + day(m_day)

daysfromnewyear = days

end function

function daysfromspringday(m_day)

dim days

dim months

days = 0

months = getnongrunyue(year(m_day))

if months < month(m_day) then

days = days + getnongrunyuedays(year(m_day))

else

if((months=month(m_day)) and isrunyue) then

days = days + getnongrunyuedays(year(m_day))

end if

end if

for i=1 to month(m_day)

days = days + getnongmonthdays(year(m_day),i,false)

next

days = days + day(m_day)

daysfromspringday = days

end function

function cal2n(n)

cal2n = 1

for i=0 to n – 1

cal2n = cal2n * 2

next

end function

function getnnamein60(index)

dim shengxiao

dim tiangan

dim dizhi

dim buffer

dim m_cur,m_this,tian,di

shengxiao = array("鼠","牛","虎","兔","龙","蛇","马","羊","猴","鸡","狗","猪")

tiangan = array("甲","乙","丙","丁","戊","己","庚","辛","壬","癸")

dizhi = array("子","丑","寅","卯","辰","巳","午","未","申","酉","戌","亥")

buffer = "农历"

m_cur = 0

m_this = 0

tian = 0

di = 0

for i=0 to 60 – 1

tian = i mod 10

di = i mod 12

if m_this = index then

buffer = buffer & tiangan(tian)

buffer = buffer & dizhi(di)

buffer = buffer & "年,"

buffer = buffer & shengxiao(di)

buffer = buffer & "年"

end if

m_this = m_this + 1

next

getnnamein60 = buffer

end function

function getganzhi(m_nongyear)

dim m_index

m_index = (m_nongyear – 1924) mod 60

getganzhi = getnnamein60(m_index)

end function

function yearisrunnian(years)

yearisrunnian = calendardata(years-m_minyear,0) and &h80

end function

function runyueislarge(years)

runyueislarge = calendardata(years-m_minyear,0) and &h40

end function

function getdaysfromstart(years)

getdaysfromstart = (calendardata(years-m_minyear,0) and &h3f)

end function

function nongmonthislarge(years,months)

nongmonthislarge = false

if(months<9) then

if(calendardata(years-m_minyear,1) and cal2n(8 – months)) then

nongmonthislarge = true

end if

else

ch=cal2n(12 – months)

ch=movebit(ch)

if(calendardata(years-m_minyear,2) and ch) then nongmonthislarge = true

end if

end function

function getnongrunyue(years)

getnongrunyue = (calendardata(years-m_minyear,2) and &h0f)

end function

function gongmonthislarge(months)

gongmonthislarge = false

if months < 8 then

if (months mod 2) <> 0 then

gongmonthislarge = true

end if

else

if ((months mod 2) = 0) then

gongmonthislarge = true

end if

end if

end function

%>

<script language="jscript" runat="server">

function movebit(num){

return num<<=4;

}

</script>

<%

dim displaynonglidate

function getdaysinmonth(imonth, iyear)

select case imonth

case 1, 3, 5, 7, 8, 10, 12

getdaysinmonth = 31

case 4, 6, 9, 11

getdaysinmonth = 30

case 2

if isdate("february 29, " & iyear) then

getdaysinmonth = 29

else

getdaysinmonth = 28

end if

end select

end function

function getweekdaymonthstartson(danydayinthemonth)

dim dtemp

dtemp = dateadd("d", -(day(danydayinthemonth) – 1), danydayinthemonth)

getweekdaymonthstartson = weekday(dtemp)

end function

function subtractonemonth(ddate)

subtractonemonth = dateadd("m", -1, ddate)

end function

function addonemonth(ddate)

addonemonth = dateadd("m", 1, ddate)

end function

dim ddate

dim idim

dim idow

dim icurrent

dim iposition

dttoday=date()

if ddate=empty then ddate=dttoday

curdate=request("curdate")

if instr(1, request.form, "subprev", 1) > 0 then

ddate = dateadd("m", -1,curdate)

elseif instr(1, request.form, "subnext", 1) > 0 then

ddate = dateadd("m", 1,curdate)

else

ddate = dateserial(year(dttoday), month(dttoday))

end if

idim = getdaysinmonth(month(ddate), year(ddate))

idow = getweekdaymonthstartson(ddate)

%>

<div id="overdiv" style="position:absolute; visibility:hide; z-index: 1;"></div>

<table width="100%" style="border-collapse: collapse" bordercolor="#cccccc" cellpadding="2" border="1">

<tr>

<form name="fmnextprev" method="post">

<input type="hidden" name="curdate" value="<%=ddate%>">

<th bgcolor="#ff8040"><input type="submit" name="subprev" value="&lt;&lt;" style="width:98%;font-weight: bold;color: #ffffff; border: 1px ridge #ffffff; background-color: #ff7f50"></th>

<th bgcolor="#676704" colspan="5"><div id="title" style="font-size: 9pt; color: #fffad7"><%=year(ddate)&" 年 "&month(ddate)& "月 "&getganzhi(year(ddate))%></div></th>

<th bgcolor="#ff8040"><input type="submit" name="subnext" value="&gt;&gt;" style="width:98%;font-weight: bold;color: #ffffff; border: 1px ridge #ffffff; background-color: #ff7f50"></th>

</form>

</tr>

<div id="detail" style="position: absolute">

</div>

<tr>

<% for iday = vbsunday to vbsaturday %><th width="14%" bgcolor="#cc9933">

<span style="font-size:9pt;color:ffffff;font-weight: bold;">

<%=replace(weekdayname(iday),"星期","")%></span> </th>

<%next %>

</tr>

<%

if idow <> 1 then

response.write vbtab & "<tr bgcolor=""cccccc"">" & vbcrlf

iposition = 1

do while iposition < idow

response.write vbtab & vbtab & "<td> </td>" & vbcrlf

iposition = iposition + 1

loop

end if

icurrent = 1

iposition = idow

do while icurrent <= idim

if iposition = 1 then

response.write vbtab & "<tr bgcolor=""cccccc"">" & vbcrlf

end if

if (icurrent = day(ddate) and (dttoday=ddate)) then

displaynonglidate = converttonongli(formatdatetime(ddate,1))

nonglibartext= getnonglimonthname(displaynonglidate) & "月" & getnonglidayname(displaynonglidate)

response.write vbtab & vbtab & "<td bgcolor=#ff8040><span style=font-size:9pt;color:ffffff;font-weight: bold;font-family: arial>" & icurrent & "</span><br>"

response.write "<div align=""right"" style=font-size:9pt;color:ffffff;>"&nonglibartext&"</div>"

response.write "</td>" & vbcrlf

else

if (iposition=7 or iposition=1) then scolor="red" else scolor="black"

displaynonglidate = converttonongli(formatdatetime(year(ddate) & "-" & month(ddate) & "-" & icurrent ,1))

nonglibartext= getnonglimonthname(displaynonglidate) & "月" & getnonglidayname(displaynonglidate)

response.write vbtab & vbtab & "<td bgcolor=""ffffff""><span style=font-size:9pt;color:"& scolor &";font-weight: bold;font-family: arial>" & icurrent & "</span><br>"

response.write "<div align=""right"" style=font-size:9pt;color:888888;>"&nonglibartext&"</div>"

response.write "</td>" & vbcrlf

end if

if iposition = 7 then

response.write vbtab & "</tr>" & vbcrlf

iposition = 0

end if

icurrent = icurrent + 1

iposition = iposition + 1

loop

if iposition <> 1 then

do while iposition <= 7

response.write vbtab & vbtab & "<td> </td>" & vbcrlf

iposition = iposition + 1

loop

response.write vbtab & "</tr>" & vbcrlf

end if

%></table>

赞(0)
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com 特别注意:本站所有转载文章言论不代表本站观点! 本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。未经允许不得转载:IDC资讯中心 » 酷月历(公、农历)-ASP教程,ASP应用
分享到: 更多 (0)

相关推荐

  • 暂无文章