I don't understand anything about Lua programming. The following script takes the current day and returns the image corresponding to the current moon phase.
I just need to modify the part that gets today's date to get tomorrow's date.
I don't know how complicated this is, I even researched about adding days and found code examples, but since I don't understand anything about Lua this search was useless.
Thank you for your help
Code: Select all
function Initialize()
iCurrentStyle=1
end
function Update()
SKIN:Bang("!DisableMeasure mMoonPhaseLua")
local today = os.date('*t')
Gday = today.day Gmonth = today.month Gyear = today.year
CalcHijriDate( Gday , Gmonth , Gyear)
SKIN:Bang('!SetOption', 'MtMoonShade', 'ImageName', "#@#\Images\\moon\\"..Hdate..".png")
return 'Moon set for Julian Date '..jd..' : image '..Hdate..".png"
end
-----------------------------------------------------------------------
function julian(year, month, day)
if (month<=2) then year = year-1 month = month+12 end
local A = math.floor(year/ 100)
local B = 2- A+ math.floor(A/ 4)
JD = math.floor(365.25* (year+ 4716))+ math.floor(30.6001* (month+ 1))+ day+ B-1524.5
return JD
end
function intPart(floatNum)
if (floatNum< -0.0000001)
then return math.ceil(floatNum-0.0000001)
else return math.floor(floatNum+0.0000001)
end
end
function CalcHijriDate( d , m , y )
jd = math.ceil( julian( y, m, d ) )
local l=jd-1937808
local n=intPart((l-1)/10631)
local l=l-10631*n+354
local j=(intPart((10985-l)/5316))*(intPart((50*l)/17719))+(intPart(l/5670))*(intPart((43*l)/15238))
local l=l-(intPart((30-j)/15))*(intPart((17719*j)/50))-(intPart(j/16))*(intPart((15238*j)/43))+29
Hmonth=intPart((24*l)/709) -- month
Hdate = l-intPart((709*Hmonth)/24) -- date
end