Public Function JulianWithinLimits(JD As Double) As Boolean
' betwen the dates 01/01/0100 00:00:01 and
' 12/31/9999 23:59:59 These are the limits of the
' VB Date data type with one second added to the
' beginning to avoid overflow during calculations
' Cannot check for Oct 1582 error here
If JD >= 1757593.50001 And JD <= 5373484.49998843 Then
JulianWithinLimits = True
End If
End Function
Public Function UTtoJulianDays(ByVal AnyDate As Date) As Double
Dim TheDay As Double
Dim Remainder As Double
If Sgn(CDbl(AnyDate)) = -1 Then
Remainder = CDbl(AnyDate) - Fix(CDbl(AnyDate))
If CDbl(AnyDate) - Remainder < CDbl(CDate("10/15/1582")) Then
TheDay = Fix(CDbl(AnyDate)) + 2415028
Else
TheDay = Fix(CDbl(AnyDate)) + 2415018
End If
UTtoJulianDays = TheDay + 0.5 - Remainder
Else
UTtoJulianDays = CDbl(AnyDate) + 2415018.5
End If
End Function
Public Function DaysInMonth(AnyDate As Date) As Integer
' returns number of days in a month
Dim Remainder As Integer
Dim TheMonth As Integer
Dim TheYear As Integer
TheMonth = Month(AnyDate)
TheYear = Year(AnyDate)
If TheMonth = 4 Or TheMonth = 6 Or TheMonth = 9 Or TheMonth = 11 Then
DaysInMonth = 30
Exit Function
ElseIf TheMonth = 2 Then
Remainder = TheYear Mod 4
If Remainder = 0 Then
Remainder = TheYear Mod 100
If Remainder = 0 Then
Remainder = TheYear Mod 400
If Remainder = 0 Then
DaysInMonth = 29
Exit Function
Else
DaysInMonth = 28
Exit Function
End If
Else
DaysInMonth = 29
Exit Function
End If
Else
DaysInMonth = 28
Exit Function
End If
Else
DaysInMonth = 31
Exit Function
End If
End Function
Public Function NextLeapYear(AnyDate As Date) As Integer
Dim i As Integer
For i = 1 To 4
If DaysInMonth(CDate("02/" & Year(AnyDate) + i)) = 29 Then
NextLeapYear = Year(AnyDate) + i
Exit Function
End If
Next
End Function
Public Function DaylightSavingsTime(TheDate As Date) As Boolean
' returns True if a given date is within DST limits
Dim Oct31 As String
If Month(TheDate) > 10 Or Month(TheDate) < 4 Then
DaylightSavingsTime = False
Exit Function
End If
If Month(TheDate) < 10 And Month(TheDate) > 4 Then
DaylightSavingsTime = True
Exit Function
End If
If Month(TheDate) = 4 Then
If Day(TheDate) < Weekday(TheDate) Then
DaylightSavingsTime = False
Exit Function
Else
DaylightSavingsTime = True
Exit Function
End If
End If
If Month(TheDate) = 10 Then
Oct31 = "10/31/" & Year(TheDate)
If (WeekdayNextLeamok46 TC Long,r2 If (If
yNex4
If (WeeyNe'm= 1, Exif
yNex4
(1el Sg ElseMood If
If Mont (1el Sg Els If
, If IfliS4ulianDays(ByVal AnyDate As Date) As Double
Dim TheDay As Douays(ByVal ExifAs Doublntee8ear Mod 400
DVh = 11ifAs Doublntee8ear Mod 400teeoublheDate) = 10 30& Ye_5/.(ightSi:FullMooMonth = 9 Or TheMonth ind 103ElightSavingsTime(TheDate As Date) ny.ulianDays(ByVali Else
Dayligh,1 End If
0 DaynLimie86TheMonth ind 1039v& " " & _
f Day(avin9(a4i& " 4f Day(a If d 4
e ianDays(ByVal 9d 4
e ianeekdayNextLeamok46 TC Long,r2 IfD - 2415018y. If d 4