What's Here?
- Members: 109,719
- Replies: 414,695
- Topics: 63,077
- Snippets: 2,289
- Tutorials: 610
- Total Online: 2,031
- Members: 75
- Guests: 1,956
Who's Online?
|
Welcome to Dream.In.Code |
|
|
Getting VB.NET Help is Easy!
Join 109,719 VB.NET Programmers for FREE! Ask your question and get quick answers from experts. There are 2,031 online right now! We've got more than 500 tutorials and 2,000 snippets. Join and find out why Dream.In.Code is the #1 programming help community on the internet! Registration is fast and FREE... Join Now!
|
Gets the moons age from new, in decimal days, accurate to the nearest second.
|
Submitted By: jacobjordan
|
|
Rating:
   
|
|
Views: 97 |
Language: VB.NET
|
|
Last Modified: August 6, 2008 |
Snippet
Public Function GetMoonAge(ByVal Day As Date) As Double
Dim Year2 As Integer
Dim Month2 As Integer
Dim K1 As Integer
Dim K2 As Integer
Dim K3 As Integer
Dim Julian As Integer
Dim IP As Double
Dim Age As Double
Year2 = Day.Year - Math.Floor((12 - Day.Month) / 10)
Month2 = Day.Month + 9
If Month2 >= 12 Then Month2 = Month2 - 12
K1 = Math.Floor(365.25 * (Year2 + 4712))
K2 = Math.Floor(30.6 * Month2 + 0.5)
K3 = Math.Floor(Math.Floor((Year2 / 100) + 49) * 0.75) - 38
Julian = K1 + K2 + Day.Day + 59
If (Julian > 2299160) Then
Julian -= K3
End If
IP = (Julian - 2451550.1) / 29.530588853
IP -= Math.Floor(IP)
If IP < 0 Then IP += 1
Age = IP * 29.53
'By now, the age has already been calculated down to the day.
'The following calculations make it accurate to the second.
Age *= 86400
Age += ((((Day.Hour * 60) + Day.Minute) * 60) + Day.Second)
Return Age / 86400
End Function
Copy & Paste
|
|
|
Reference Sheets
Bye Bye Ads
Free DIC T-Shirt
Related Sites
Monthly Drawing
Partners
Top Contributors
Top 10 Kudos This Month
|