Hi All
I am trying to write a script that loads a text file and announces messages....
Eg.
$Start_Date,$End_Date,$Message
12/11/2013, 12/16/2013, Concert in the Park this week
Etc.
Problem I have is that EZ-Script runs a calculation on the dates so that they become month divided by Day divided by year... So as a work around I separated the date into integers.
Eg.
$Start_Month, $Start_Day, $Start_Year, $End_Month, $End_Day, $End_Year, $Message
12, 11, 2013, 12, 16, 2012, Happy Birthday George
Now it seems to me the best way to compare the Start_dates and End_Dates with the current date is to convert them to a digital format first (Preventing complications when dates cross years).
My question for the masses is :
Has anyone got a script to convert a Georgian date into a Julian number?
I can only find complicated formula and ready made converters.
I need to be able to take the three variables $X_Day, $X_Month and $X_Year and end up with a Julian number.
@Tameion
Asked
— Edited
Georgian to Julian is a very complex formula from what I remember... Is there not an easier way of doing it?
Anyway I thought I'd post the result here .... it's a little spaghetti and I had to loop it a bit as I had to use the Round function to fill in for the lack of integer function... but where there is a will there is a way.
The calculator will give you the current date as a Julian. Then what ever other date yu convert can be compared to this for an past or future comparison.
#Julian Date Calculator
# Credit to http://quasar.as.utexas.edu/BillInfo/JulianDatesG.html
$Y=$Year
$M=$Month
$D=$Day
$A1 = $Y/100
$A2=Round($A1,0)
IF ($A1<$A2)
$A=$A2-1
ElseIF ($A1>=$A2)
$A=$A2
ENDIF
$B1 = $A/4
$B2=Round($B1,0)
IF ($B1<$B2)
$B=$B2-1
ElseIF ($B1>=$B2)
$B=$B2
Endif
$C1 = 2 - $A + $B
$C2=Round($C1,0)
IF ($C1<$C2)
$C=$C2-1
ElseIF ($C1>=$C2)
$C=$C2
ENDIF
$E1 = 365.25 * ($Y+4716)
$E2=Round($E1,0)
IF ($E1<$E2)
$E=$E2-1
ElseIF ($E1>=$E2)
$E=$E2
ENDIF
$F1 = 30.6001 * ($M+1)
$F2=Round($F1,0)
IF ($F1<$F2)
$F=$F2-1
ElseIF ($F1>=$F2)
$F=$F2
ENDIF
$JD= $C + $D + $E + $F - 1524.5
Print ($JD)