# still problem with JD algorithm

6 posts / 0 new
pox
still problem with JD algorithm

Hi,

Thought I'd cracked this, but obviously not!

While reporting my obs 2 nights ago using the charting/reporting tool I have written, the JD was 1 day too late, and I have also had a reply to the same effect by my one and only user so far. Here is what I am using (VB6) which comes from this forum ex Meeus, with small changes - I don't need negative dates for obvious reasons! Below gives just the julian day - the decimal of the time is added to the result.

Public Function julian(Y As Integer, m As Integer, d As Integer) As Long
Dim a As Integer, b As Integer
a = Int(Y / 100)
b = 2 - a + Int(a / 4)
If m > 2 Then
'do nothing
Else
Y = Y - 1
m = m + 12
End If
julian = Int(365.25 * (Y + 4716)) + Int(30.6001 * (m + 1)) + d + b - 1524.5
End Function

David Benn
Comparison

Happy to compare notes with my implementation. Looks very much the same as:

If you want to compare results of specific date tests, let me know.

David

pox
Thanks David, looks as though

Thanks David, looks as though you include the day (decimal and all) as one of the parameters, whereas I add it on after the 'integer' JD (without decimal) has been returned. Could be that's what is giving me the wrong result, so I shall give that a try. Many thanks.

David Benn
Day

Hi Michael

Yep, that makes sense. When I looked quickly at your code above I didn't notice the integer type for day in your function's parameter list. As you say, mine is of a real type:

public double calendarToJD(int year, int month, double day)

...

David

pox
Hi David,

Hi David,

Yes, that did it! Just ran the new code and everything correct to 4 dp. Cheers!

David Benn
Nice

David