It is currently April 26th, 2024, 1:00 pm

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

Need help to create a new calendar skin

Post by edei890 »

hello, :welcome:

I'm new in creating skin for rainmeter.. rather fresh to be precise.. :D
this is actually my first try to create one..
hope the community can help me through with this..

the idea is to create a hijrah calendar that has different day count every year for each month..
for example for the first month of this year it would have 30 days, then for the next year it would have 29 days..

is there any way that you guys can point on how to do it?..

thanks for all the help from you guys in advance.. ;-)
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 »

I don't want to discourage you, but before you start, you should understand that this is going to be an extremely challenging project, especially for a beginner. I've been using Rainmeter for four years, and calendar math still eludes me much of the time. If you have literally no experience with Rainmeter, I strongly urge you to go through the tutorials before you attempt something this complex.

Now, with that said: could you explain what you're trying to do in a little more detail? It sounds like this "calendar" will not be following the rules of real-world timekeeping. So it would help to define exactly what rules it will follow. Second, what is the calendar going to look like? A table? A list? A grid?

I guarantee, the more forethought you put into this plan, the easier it will be.
User avatar
edei890
Posts: 11
Joined: July 9th, 2012, 1:08 am

Re: Need help to create a new calendar skin

Post by edei890 »

really?.. thanks for the link to the tutorials.. still trying to understand on how to create one though.. haha.. anyway thanks for the reply earlier..

even if it is hard to do, but I still think that i wanna try to create this calendar..
I tried to look into skin that have calendar.. but all that I could understand that the regular skin calendar only read from your system calendar right?..

as for what you ask me to explain more,
1st, the calendar i'm trying to make is usually use for Muslim.. the only similarity it have with the gregorian calendar is that both have 12 months.. in hijrah calendar it have 354 to 355 days per year.. Because a hijra or Islamic lunar year is between 10 and 12 days shorter than a civil year, it begins 10–12 days earlier in the civil year following the civil year in which the previous hijri year began.

there is a calculation to convert the dates from gregorian calendar to hijra calendar, but I do not know if you could use rainmeter to do the calculation.. I even found a javascript that can be use to convert the date of your system calendar to hijra calendar..

as for the looks, I just want it to show only the date, month, and year.. as I like it to look simple and nice.. for example date skin for Morph by minhtrimatrix..

hopes my explanation would answer your question :D
User avatar
smurfier
Moderator
Posts: 1931
Joined: January 29th, 2010, 1:43 am
Location: Willmar, MN

Re: Need help to create a new calendar skin

Post by smurfier »

Could you please provide a link to the javascript you found?
GitHub | DeviantArt | Tumblr
This is the song that never ends. It just goes on and on my friends. Some people started singing it not knowing what it was, and they'll continue singing it forever just because . . .
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 link.. but it is to use as a widget for a web.. just realize it.. sorry guys..
http://www.al-habib.info/islamic-calendar/hijricalendartext.htm
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 »

It's quite easy to covert the javascript to Lua and use that to display the OS date in the Islamic Date format with Rainmeter. However, that is the easy bit and it will be quite a feat to develop a Muslim or Hijri calendar using Rainmeter even if it is based on an existing Gregorian calendar skin. Hats off and a glass of cold water/ hot tea to anyone who can crack that one!

.ini file

Code: Select all

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

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

;=== [  meters  ]
[MtBackGround1]
Meter=IMAGE
SolidColor=203CC7
W=340
H=30
UpdateDivider=-1

[MtShowGregorianDate]
Meter=STRING
MeterStyle=stext
X=5
Y=5
UpdateDivider=3600

[MtBackground2]
Meter=IMAGE
SolidColor=168221
Y=33
W=340
H=30
UpdateDivider=-1

[MtShowIslamicDate]
Meter=STRING
MeterStyle=stext
X=5
Y=38
UpdateDivider=3600

[MtBackground3]
Meter=IMAGE
SolidColor=168221
Y=66
W=340
H=30
UpdateDivider=-1

[MtShowTextDate]
Meter=STRING
MeterStyle=stext
StringAlign=CENTER
X=170
Y=71
UpdateDivider=3600

;===  [  style ] 
[sText]
FontSize=12
StringStyle=BOLD
StringAlign=LEFT
StringEffect=SHADOW
FontColor=ffffff
FontEffectColor=000000
AntiAlias=1
KuwaitAlgo.lua

Code: Select all

function Update()       
			 today = os.time(os.date('!*t'))
			 day = os.date("%d", today)
			 month = os.date("%m", today)
			 year = os.date("%Y", today)  
			 -- ----[ 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', 'MtShowTextDate', 'Text',  writeIslamicDate(addday) )
			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-1  --  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) 
		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)
		outputIslamicDate = (" "..wdNames[iDate[4]]..", "..iDate[5].." "..iMonthNames[iDate[6]].." "..iDate[7].." AH")
		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
Islamic Date.jpg
You do not have the required permissions to view the files attached to this post.
Alex Becherer

Re: Need help to create a new calendar skin

Post by Alex Becherer »

if i understood the question correctly, it's about the current date anyways.

bravissimo Mordasius!!!

i would have been lazy and just used the web parser plugin and read the date from a website.
http://customize.org/rainmeter/skins/89798
User avatar
smurfier
Moderator
Posts: 1931
Joined: January 29th, 2010, 1:43 am
Location: Willmar, MN

Re: Need help to create a new calendar skin

Post by smurfier »

Mordasius: You're doing something the hard way. Here's the easy way.

Code: Select all

	today = os.date('!*t')
	day = today.day
	month = today.month
	year = today.year
No need to convert to numbers as they already are.
GitHub | DeviantArt | Tumblr
This is the song that never ends. It just goes on and on my friends. Some people started singing it not knowing what it was, and they'll continue singing it forever just because . . .
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 »

I was thinking that edei890 was looking for something like that on Islamic Finder but with only the Red Hijri calendar showing. I looked at the website and there is certainly a chunk of stuff that might be used to replicate the calendar shown but I couldn't figure it out.
islamic_finder.jpg
But going back to basics, it should be possible to produce a Rainmeter version of the Hijri Calender once (as noted by Kaelri) the basic parameters are defined. Let's not forget that the Gregorian Calendar didn't surface until 1582 while the Tabular Islamic Calendar was introduced by Muslim astronomers in the 9th Century. Among the challenges to converting Gregorian calendars to Hijiri calendars are that the Islamic day begins at sunset and that there are different interpretations of when to add days to keep the calendar months in step with the lunar phases. But hey, where is the fun without a bit of a challenge!

P.S. good to see 'Moshi' has come out of hibernation, I'm a great fan of his stylish creations.

P.P.S.
smurfier wrote:Maordasius: You're doing something the hard way. Here's the easy way.
....
No need to convert to numbers as they already are.
Thanks for correcting that smurfier as it's the only way I'm going to learn... I'm still trying really hard to translate what's in "Beginning Lua Programming" to stuff I can use with Rainmeter. I have to admit that it's a real simple mistake when compared with some of the convoluted and inefficient hoops I create and jump through to use Tables.
:)
You do not have the required permissions to view the files attached to this post.
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 really² appreciate to you guys.. to Mordasius especially.. I tried it and it work!.. i'm gonna cry now.. :-( .. haha

but I still have questions for you guys.. is it possible for me to put a little graphic to it rather just having plain text?.. and can I somehow make it not showing the name of the day?..

the actual look that I'm looking for is in the attachment.. so I want to know is it possible to achieve this by using the code provided by Mordasius?.. I'm not asking you guys to do the ini file.. its just I want to know can we get it to look like that..


*edited by edei890*
You do not have the required permissions to view the files attached to this post.