It is currently April 27th, 2024, 7:01 am

Need help to create a new calendar skin

Get help with creating, editing & fixing problems with skins
User avatar
edei890
Posts: 11
Joined: July 9th, 2012, 1:08 am

Re: Need help to create a new calendar skin

Post by edei890 »

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..

Code: Select all

      outputIslamicDate = (" "..iDate[5].." ")
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.
User avatar
Kaelri
Developer
Posts: 1721
Joined: July 25th, 2009, 4:47 am

Re: Need help to create a new calendar skin

Post by Kaelri »

edei890 wrote:is there any other way to reduce the .lua file to only one file?..
I'm sure there is. Can you post the skin (.INI) and script (.LUA) files that you're using? Ideally all together in a ZIP file, if that's possible.
User avatar
edei890
Posts: 11
Joined: July 9th, 2012, 1:08 am

Re: Need help to create a new calendar skin

Post by edei890 »

here is the zip file
You do not have the required permissions to view the files attached to this post.
User avatar
Kaelri
Developer
Posts: 1721
Joined: July 25th, 2009, 4:47 am

Re: Need help to create a new calendar skin

Post by Kaelri »

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:

Code: Select all

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","Rabi'al-Awwal","Rabi al-Akhir","Jumada I","Jumada II","Rajab","Sha'ban","Ramadan","Shawwal","Dhu al-Qi'da","Dhu al-Hijja"}
      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
Then I just created additional !SetOption bangs at the top:

Code: Select all

         SKIN:Bang('!SetOption', 'MtShowYear', 'Text',  writeIslamicDate(addday, 'year') )
         SKIN:Bang('!SetOption', 'MtShowMonth', 'Text',  writeIslamicDate(addday, 'month') )
         SKIN:Bang('!SetOption', 'MtShowDate', 'Text',  writeIslamicDate(addday, 'date') )
I tried to incorporate the other changes you made to Mordasius's script; apologies if I missed anything. Complete skin and script below.
Calendar.ini

Code: Select all

[Rainmeter]
Author=Mordasius
MiddleMouseUPAction=!Refresh
Update=1000

[BG]
Meter=IMAGE
ImageName=bg.png
X=0
Y=0

;===  [  measures   ]
[MsAlgo]
Measure=SCRIPT
ScriptFile=#CURRENTPATH#KuwaitAlgo.lua
UpdateDivider=3600

;=== [  meters  ]

[MtShowYear]
Meter=STRING
MeterStyle=stext
StringAlign=CENTER
X=52
Y=104
UpdateDivider=3600

[MtShowMonth]
Meter=STRING
MeterStyle=stext
StringAlign=CENTER
X=52
Y=-15r
UpdateDivider=3600

[MtShowDate]
Meter=string
MeterStyle=sText2
StringAlign=CENTER
X=47
Y=0
UpdateDivider=3600


;===  [  style ]
[sText]
FontFace=Segoe UI
FontSize=10
StringAlign=LEFT
FontColor=ffffff
FontEffectColor=000000
AntiAlias=1

[sText2]
FontFace=Segoe UI
FontSize=50
StringAlign=LEFT
FontColor=ffffff
FontEffectColor=000000
AntiAlias=1
KuwaitAlgo.lua

Code: Select all

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
User avatar
Mordasius
Posts: 1173
Joined: January 22nd, 2011, 4:23 pm
Location: GMT +8

Re: Need help to create a new calendar skin

Post by Mordasius »

You forgot to include smurfier's corrections to my cumbersome os.date stuff in function update() of the KuwaitAlgo.lua file!

Code: Select all

today = os.date('!*t')
   day = today.day
   month = today.month
   year = today.year
User avatar
Kaelri
Developer
Posts: 1721
Joined: July 25th, 2009, 4:47 am

Re: Need help to create a new calendar skin

Post by Kaelri »

Whoops, so I did. Fixed. :)
User avatar
edei890
Posts: 11
Joined: July 9th, 2012, 1:08 am

Re: Need help to create a new calendar skin

Post by edei890 »

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.
User avatar
Kaelri
Developer
Posts: 1721
Joined: July 25th, 2009, 4:47 am

Re: Need help to create a new calendar skin

Post by Kaelri »

Of course. :)
User avatar
Mordasius
Posts: 1173
Joined: January 22nd, 2011, 4:23 pm
Location: GMT +8

Re: Need help to create a new calendar skin

Post by Mordasius »

edei890 wrote:I'll translate the name of the days and months back and I think I want to make it as a official release..
By all means do so. I think just about everything here is share-alike.

If you are changing the month names, could you change them to:

Code: Select all

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.
User avatar
edei890
Posts: 11
Joined: July 9th, 2012, 1:08 am

Re: Need help to create a new calendar skin

Post by edei890 »

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?! :o .. 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?..