I did manage to make it look like what I want it to.. what I did was to create .lua file for each year, date, and month.. only edited this part from the original .lua.. everything else just as the original..
is there any other way to reduce the .lua file to only one file?..
I don't know how to edit more than this because I'm not familiar with any coding language..
just using some trial and error method and this is what I come out with :
You do not have the required permissions to view the files attached to this post.
Ok. What I did was modify the writeIslamicDate() function to accept a second parameter: 'year', 'month' or 'date'. The function returns a different value based on this parameter:
function Update()
today = os.date('!*t')
day = today.day
month = today.month
year = today.year
-- ----[ the following can be used for testing ]
-- day =1
-- month = 6
-- year = 2012
-- print("test date: "..day.." / "..month.." / "..year)
-- --------------------------------
addday=0
SKIN:Bang('!SetOption', 'MtShowGregorianDate', 'Text', ("Gregorian Date : "..day.." / " ..month.." / "..year))
tIslamicDate = kuwaiticalendar(addday)
SKIN:Bang('!SetOption', 'MtShowIslamicDate', 'Text', ("Islamic Date : "..tIslamicDate[5].." / " ..tIslamicDate[6].." / "..tIslamicDate[7]))
SKIN:Bang('!SetOption', 'MtShowYear', 'Text', writeIslamicDate(addday, 'year') )
SKIN:Bang('!SetOption', 'MtShowMonth', 'Text', writeIslamicDate(addday, 'month') )
SKIN:Bang('!SetOption', 'MtShowDate', 'Text', writeIslamicDate(addday, 'date') )
return 'dates refreshed....'
end -- function Update
function kuwaiticalendar(adjust)
local day=tonumber(day)
local m = tonumber(month)
local y = tonumber(year)
if (m<3) then y = y-1 m = m+12 end
a = math.floor(y/100)
b = 2-a+math.floor(a/4)
if (y<1583) then b = 0 end
if (y==1582) then
if (m>10) then b = b-10 end
if (m==10) then b = 0 end
if (day>4) then b = b-10 end
end
jd = math.floor(365.25*(y+4716))+math.floor(30.6001*(m+1))+day+b-1524
b = 0
if (jd>2299160) then
a = math.floor((jd-1867216.25)/36524.25)
b = 1+a-math.floor(a/4)
end
bb = jd+b+1524
cc = math.floor((bb-122.1)/365.25)
dd = math.floor(365.25*cc)
ee = math.floor((bb-dd)/30.6001)
day =(bb-dd)-math.floor(30.6001*ee)
month = ee-1
if (ee>13) then
cc = cc+ 1
month = ee-13
end
year = cc-4716
if (adjust) then wd = gmod(jd+1-adjust,7)+1
else wd = gmod(jd+1,7)+1
end
iyear = 10631./30.
epochastro = 1948084
epochcivil = 1948085
shift1 = 8.01/60.
z = jd-epochastro
cyc = math.floor(z/10631.)
z = z-10631*cyc
j = math.floor((z-shift1)/iyear)
iy = 30*cyc+j
z = z-math.floor(j*iyear+shift1)
im = math.floor((z+28.5001)/29.5)
if (im==13) then im = 12 end
id = z-math.floor(29.5001*im-29)
myRes = {}
myRes[0] = day -- calculated day (CE)
myRes[1] = month-1 -- calculated month (CE)
myRes[2] = year -- calculated year (CE)
myRes[3] = jd -- julian day number
myRes[4] = wd -- weekday number
myRes[5] = id -- islamic date (modified with -1)
myRes[6] = im -- islamic month
myRes[7] = iy -- islamic year
return myRes
end -- of kuwaiticalendar
function gmod(n,m)
return ((n%m)+m)%m
end
function writeIslamicDate(adjustment, ReturnValue)
local wdNames = {"al-Ahad","al-Ithnayn","ath-Thalaathaa","al-Arba‘aa’","al-Khamis","al-Jumu‘ah","as-Sabt"}
local iMonthNames = {"Muharram","Safar","Rabiul-Awwal","Rabiul-Akhir","Jamadil Awwal","Jamadil Akhir","Rejab","Sya'ban","Ramadan","Syawal","Dhulqaedah","Dhulhijja"}
local iDate = kuwaiticalendar(adjustment)
if ReturnValue == 'year' then
outputIslamicDate = (" "..iDate[7].." Hijrah")
elseif ReturnValue == 'month' then
outputIslamicDate = (" "..iMonthNames[iDate[6]].." ")
elseif ReturnValue == 'date' then
outputIslamicDate = (" "..iDate[5].." ")
end
return outputIslamicDate
end -- of writeIslamicDate
--[][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][]][][][][][][][][][][][][][][][][][][][][][][][]][][][][][][][][][][][][][][][][][][][
-- The script was 'translated' from JavaScript on alhabib -> http://www.al-habib.info/islamic-calendar/hijricalendartext.htm
-- The Islamic Month and Day Number were both adjusted (+/- 1) to be more consistent with results from the sites listed below.
-- The adjustment value has been left in but setting it to =1 does not seem to produce more consitent results.
--
-- 1) http://www.muslimphilosophy.com/ip/hijri.htm
-- 2) http://www.oriold.uzh.ch/static/hegira.html
-- 3) http://www.islamicfinder.org
Thanks a lot!
If I could shake hands with you, I would shake like there is no tomorrow!..
haha.. I would like to thanks to all you guys for helping..
credits goes to: Mordasius
Kaelri
smurfier
and to everyone that contributing in helping me to create this calendar..
this time I include smurfier's corrections, did a few translation
for name of the days and month that used in Malaysia..
from Kaelri explanation, I add a few line and manage to show the day too..
and the result, Voila!
Calendar.png
I'll translate the name of the days and months back and I think I want to make it as a official release..
so I want to ask you guys permission if I may to do so..
You do not have the required permissions to view the files attached to this post.
local iMonthNames = {"Muharam","Safar","Rabi'ul Awal","Rabiul Akhir","Jamadil Awal","Jamadil Akhir","Rajab","Sha'ban","Ramadhan","Shawwal","Dhulka'edah","Dzulhijjah"}
The ones I used before were from Wikipedia and don't look quite right (esp. "Jumada I","Jumada II").
Just out of interest, I've come across a better javascript that sets the gregorian and hijri dates on www.arabnews.com (top left). I'm now trying to find a way to display the hijri date in arabic script as follow-up to Alex's suggestion to just grab the date from a website.
Mordasius wrote:I'm now trying to find a way to display the hijri date in arabic script as follow-up to Alex's suggestion to just grab the date from a website.
it will show the date in arabic script?! .. what thrills.. haha
but if you grab the from a website, then does it also mean that
you would need to have a Internet connection to be able to use it?..