Public Class Tester
Public Shared Sub Main
Dim phaseDay As Double
Dim result As String
phaseDay = MoonPhase(Now.ToUniversalTime)
result = "UTC is now: " & _
Now.ToUniversalTime.ToString("u") & vbNewLine & vbNewLine
If (phaseDay < 0) Then
result &= "Approx days until new moon: " & _
(-phaseDay).ToString("F1")
Else
result &= "Approx days since new moon: " & _
phaseDay.ToString("F1")
End If
Console.WriteLine(result)
End Sub
Public Shared Function MoonPhase(ByVal dateUtc As Date) As Double
Dim days As Double = dateUtc.Subtract(#1/1/1600#).TotalDays
Dim cycles As Double = days * 0.03386319 - 12.5
Return Math.IEEERemainder(cycles, 1.0) * 29.53059
End Function
End Class
UTC is now: 2007-05-12 04:09:30Z
Approx days until new moon: 4.7
5.1.Date |
| 5.1.1. | Dim thirdOfJuly As Date = #7/3/1776 11:59:59 PM# |
| 5.1.2. | Dim fourthOfJuly As New Date(1776, 7, 4) |
| 5.1.3. | Dim inTheMorning As New Date(1776, 7, 4, 9, 45, 30) |
| 5.1.4. | dateVariable = #1/1/2004# |
| 5.1.5. | dateVariable = #8/27/2001 6:29:11 PM# |
| 5.1.6. | dateVariable = 'July 2, 2002' |
| 5.1.7. | Add 3 years to a date |
| 5.1.8. | Date AddYears, AddMonths and AddDays |
| 5.1.9. | Add Time to current time |
| 5.1.10. | Elapsed Ticks |
| 5.1.11. | Subtract Time |
| 5.1.12. | Date ToString, ToLongDateString, ToShortDateString, ToLongTimeString, ToShortTimeString and ToUniversalTime |
| 5.1.13. | System Time |
| 5.1.14. | Moon Phase |
| 5.1.15. | Parse Date: Test an invalid date |
| 5.1.16. | Date and TimeSpan |
| 5.1.17. | ToLongDateString |
| 5.1.18. | ToLongTimeString |
| 5.1.19. | Date.ToOADate |
| 5.1.20. | Get Ticks from DateTime |
| 5.1.21. | Compare Date value in If statement |
| 5.1.22. | Select Day Of Week |