Private Function SolarDays(ByVal Y As Integer, ByVal m As Integer) As Integer If m = 2 Then If (Y Mod 4 = 0 And Y Mod 100 <> 0) Or (Y Mod 400 = 0) Then SolarDays = 29 Else SolarDays = 28 End If Else SolarDays = SolarMonth(m - 1) End If End Function
'某y年的第n个节气的日期(从0小寒起算) OK
Private Function sTerm(ByVal Y, n As Integer) As Date Dim D1, D2 As Double D1 = (31556925.9747 * (Y - 1900) + sTermInfo(n) * 60#) D2 = DateDiff("s", "1970-1-1 0:0", "1900-1-6 2:5") + D1 D1 = D2 / 2 sTerm = DateAdd("s", D2 - D1, DateAdd("s", D1, "1970-1-1 0:0")) sTerm = Format(sTerm, "yyyy/mm/dd") End Function
'根据年份返回属象 OK Private Function Animal(ByVal sYear As Integer) As String Animal = Animals((sYear - 1900) Mod 12) End Function
'根据阳历返回其节气,若不是则返回空 OK Private Function GetTerm(ByVal sDate As Date) As String Dim Y, m As Integer Y = Year(sDate) m = Month(sDate) GetTerm = "" If sTerm(Y, m * 2 - 1) = sDate Then GetTerm = SolarTerm(m * 2 - 1) ElseIf sTerm(Y, m * 2 - 2) = sDate Then GetTerm = SolarTerm(m * 2 - 2) End If End Function