Hi,

Anyone have a function to convert the Time to Julian Time?

Rui

Hi,

Anyone have a function to convert the Time to Julian Time?

Rui

you mean DATE, there is no such thing as “julian time”

[quote]

Many applications (especially mainframe systems) store dates in the Julian format, which is a 5 digit number, consisting of a 2 digit year and a 3 digit day-of-year number. For example, 24-August-1999 is stored as 99236, since 24-August is the 236th day of the year. Excel doesn’t support Julian dates directly, but you can use them with only a few fairly simple formulas.[/quote]

```
dim d as new date
dim julian as string
julian=format((d.year mod 100),"00")+format(d.dayofyear,"000")
```

I did a lot of reading about Julian time years ago and came to the conclusion that it is very complex. Paupes made many changes to Julian time. Gregorian time on the other hand is very predictable, Julian time is not. But I can be wrong.

This is what I have, but I’m have dificult to calculate h: m: s to generate julian time

[quote] dim dd As date

dim vmonth,vday,vyear,temp,day_number,vhour,vmin,vsec,time_number As Integer

dd=new date

vmonth = d.Month

vday = dd.day

vyear = dd.year

vhour = dd.Hour

vmin =dd.Minute

vsec = dd.Second

temp = (14 - vMONTH) / 12

day_number = vDAY - 32075 + (1461 * (vYEAR + 4800 - temp) / 4)+ ((367 * (vMONTH - 2 + temp * 12)) / 12) - ((3 * ((vYEAR + 4900 - temp) /100)) /4)

time_number = vhour + (vmin + vsec/60.0)/60./24.0

label8.Text = "Julian Date/Time (JD): " + str(day_number) + “.” + str(time_number)

[/quote]

Correction of the code.

I still do not have the desired results in time_number.

[quote] dim dd As date

dim vmonth,vday,vyear,temp,day_number,vhour,vmin,vsec,time_number As Integer

dd=new date

vmonth = dd.Month

vday = dd.day

vyear = dd.year

vhour = dd.Hour

vmin =dd.Minute

vsec = dd.Second

temp = (14 - vMONTH) / 12

day_number = vDAY - 32075 + (1461 * (vYEAR + 4800 - temp) / 4)+ ((367 * (vMONTH - 2 + temp * 12)) / 12) - ((3 * ((vYEAR + 4900 - temp) /100)) /4)

time_number = (vhour + (vmin + vsec/60)/60)/24

time_number = time_number - 0.5

label8.Text = "Julian Date/Time (JD): " + str(day_number) + “.” + str(time_number)

[/quote]

The way it is done for astronomical applications is here:

http://mathforum.org/library/drmath/view/51907.html

There is also a surprisingly simple formula to convert JD back to year/month/day.

You really should obtain a copy of Jean Meeus’ book “Astronomical Formulae for Calculators” as this describes how to deal with longitude and local time vs the ephemeris time used to compute the position of astronomical objects.

It explains how to compute the moons phase and position etc properly, plus the sun and planets.

The forumulae from Meeus should agree with your results to the last digit, otherwise you have made a mistake. Many years ago I programmed an ephemeris of sun moon and planets for a HP41CX calculator which worked correctly to 12 places.

For trivial application you use the “Modified Julian Date” (MJD) or alternatively use the JD for January 0 of the least year of interest and subtract that off the JD.

Forum for Xojo Programming Language and IDE. Copyright © 2024 Xojo, Inc.