Julian Date
-
Topic authorElPelado
- Posts: 862
- Joined: 07.04.2003
- With us: 21 years 8 months
- Location: Born in Argentina
- Contact:
Julian Date
how i convert julian date to "normal dat" and the oposite?
---------X---------
EL XENTENARIO
1905-2005
My page:
http://www.urielpelado.com.ar
My Gallery:
http://www.celestiaproject.net/gallery/view_al ... y-Universe
EL XENTENARIO
1905-2005
My page:
http://www.urielpelado.com.ar
My Gallery:
http://www.celestiaproject.net/gallery/view_al ... y-Universe
-
- Posts: 73
- Joined: 27.06.2002
- With us: 22 years 5 months
- Location: Germany
- Contact:
Hi ElPelado,
i`ve asked this question for a long time and i got this Link as answer:
http://aa.usno.navy.mil/data/docs/JulianDate.html
hope it helps you.
i`ve asked this question for a long time and i got this Link as answer:
http://aa.usno.navy.mil/data/docs/JulianDate.html
hope it helps you.
Celestia on my System:
AMD Barton 2800+@3000+
1024 MB DDR-RAM
ATI Radeon 9500 non Pro 128MB
_________________
However if God is a mistake, then I do not regret anything. More worth living than this mistake did not give it.
AMD Barton 2800+@3000+
1024 MB DDR-RAM
ATI Radeon 9500 non Pro 128MB
_________________
However if God is a mistake, then I do not regret anything. More worth living than this mistake did not give it.
Here's a way to do it. It's written in the form of a Visual Basic function so it should be pretty easy to follow.
Code: Select all
Function JulianToDate(ByVal plJulian As Long) As Date
Dim sJulian As String
Dim bCentury As Byte
Dim iYear As Integer
Dim iDay As Integer
' Pad with leading zeros
sJulian = String(6 - Len(CStr(plJulian)), "0") + CStr(plJulian)
' Breakdown...
bCentury = CByte(Left(sJulian, 1))
iYear = (1900 + (bCentury * 100) + CByte(Mid(sJulian, 2, 2)))
iDay = CInt(Mid(sJulian, 4, 3))
' Return the gregorian date
JulianToDate = DateAdd("d", iDay - 1, DateSerial(iYear, 1, 1))
End Function
-
Topic authorElPelado
- Posts: 862
- Joined: 07.04.2003
- With us: 21 years 8 months
- Location: Born in Argentina
- Contact:
thank you both!
jrobert: can you explain me where to put that code? i used the visual basic, but i forgot...
jrobert: can you explain me where to put that code? i used the visual basic, but i forgot...
---------X---------
EL XENTENARIO
1905-2005
My page:
http://www.urielpelado.com.ar
My Gallery:
http://www.celestiaproject.net/gallery/view_al ... y-Universe
EL XENTENARIO
1905-2005
My page:
http://www.urielpelado.com.ar
My Gallery:
http://www.celestiaproject.net/gallery/view_al ... y-Universe
Rather than trying to explain it (which is something I'm not very good at when it comes to code ), I'll paste the contents of the form1.frm file here... All you need to do is copy/paste it into a blank text file and rename it to form1.frm.
Code: Select all
VERSION 5.00
Begin VB.Form Form1
Caption = "Form1"
ClientHeight = 1545
ClientLeft = 1620
ClientTop = 1755
ClientWidth = 2610
LinkTopic = "Form1"
ScaleHeight = 1545
ScaleWidth = 2610
Begin VB.CommandButton Command1
Caption = "Get Date"
Default = -1 'True
Height = 375
Left = 120
TabIndex = 2
Top = 1080
Width = 2295
End
Begin VB.TextBox Text1
Height = 375
Left = 120
TabIndex = 1
Text = "<Enter Julian Number Here>"
Top = 600
Width = 2235
End
Begin VB.Label Label1
Height = 375
Left = 120
TabIndex = 0
Top = 120
Width = 2295
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Function JulianToDate(ByVal plJulian As Long) As Date
Dim sJulian As String
Dim bCentury As Byte
Dim iYear As Integer
Dim iDay As Integer
' Pad with leading zeros
sJulian = String(6 - Len(CStr(plJulian)), "0") + CStr(plJulian)
' Breakdown...
bCentury = CByte(Left(sJulian, 1))
iYear = (1900 + (bCentury * 100) + CByte(Mid(sJulian, 2, 2)))
iDay = CInt(Mid(sJulian, 4, 3))
' Return the gregorian date
JulianToDate = DateAdd("d", iDay - 1, DateSerial(iYear, 1, 1))
End Function
Private Sub Command1_Click()
If IsNumeric(Text1) And Len(Text1) <= 6 Then
Label1 = JulianToDate(Text1)
End If
Text1.SetFocus
Text1_GotFocus
End Sub
Private Sub Text1_GotFocus()
Text1.SelStart = 0
Text1.SelLength = Len(Text1)
End Sub
Private Sub Text1_Validate(cancel As Boolean)
If Not (IsNumeric(Text1) And Len(Text1) <= 6) Then
cancel = True
Text1.SetFocus
End If
End Sub