将以下文件保存为 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="<<" 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=">>" 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
关于我们 / 给我留言 / 版权举报 / 意见建议 / 网站编程QQ群
Copyright ©2003-
2024 Lihuasoft.net webmaster(at)lihuasoft.net 加载时间 0.00474
|