Julian Date Function

Does anyone out there have a function to convert a date to Julian Date?

Look here. It’s easy to convert to Xojo. Or better this Library but more work,

Actual Julian date, ie days since January 1, 4713 BC ?

or the pseudo Julian Date that appears in financial files like BACS, where it is YYDDD eg 17026 … 26 days into the year 2017?

I’m trying to convert a function written in VB to calculate the moon phase and it takes Julian Date as input and Xojo doesn’t have a function that does that

https://forum.xojo.com/22139-time-to-julian-date/0

Thanks Dave, I found a piece of code you posted a while back regarding moon phase

phase = (julian_date + 4.867) / 29.53059;
phase = phase -Floor(phase);

I keep getting Zero back, even though I am trying different dates, since I think we are a new moon now
Basically I want to find out current moon phase then post the textual description ie) waxing gibbous etc

For instance, the first line for today returns 587.6919 but after the 2nd line, I get 0

And isn’t 587 a rather large # for moon age?, I was expecting something like 29 (since we are close to new moon)

is PHASE defined as a single, double, Integer?

if at the first line the answer is 587.6919 then after the second it should be 0.6919

587.5919-587.0000

assuming PHASE is not an integer datatype

Double

Now at .6911 I need to convert that to something like Waning Gibbous a textual description. so now I guess I need to find the moon age in days?

Sorry it was integer in the call, but double in the method

So the number.6911 represents?. Sorry for the lack of understanding, new at this stuff

I just ran an api call and it gave me “time”:1513483200,
“summary”:“Breezy and mostly cloudy throughout the day.”,
“icon”:“wind”,
“sunriseTime”:1513511544,
“sunsetTime”:1513542493,
“moonPhase”:0.98,

Sorry… I don’t have the resources available to go through that code at the moment

No worries, thanks for what you provided, it is a good start Dave