It is currently May 1st, 2024, 6:40 am

problem in creating analoge date

Get help with creating, editing & fixing problems with skins
hack_er4
Posts: 4
Joined: August 19th, 2012, 6:35 am

problem in creating analoge date

Post by hack_er4 »

Hello friends,
I am creating a analog clock with analog day,date and month.
I am succeeded in analog day and month as they are linear.
but with date I can't able to write the script as every month end the keep on changing like jan 31
feb 28 and 29
mar 30
apr 31
.
.
.
.
.
dec 31

Is there any way to get those right every month? :-(

Thanks,
User avatar
TweaknFreak
Posts: 217
Joined: July 14th, 2012, 7:26 am

Re: problem in creating analoge date

Post by TweaknFreak »

Check out the code of this. Might be helpful.

http://limpet.deviantart.com/art/Rainmeter-Calendar-106839760
Be one of the iNEViTABLES - Storm, Earthquake, Lightning, Flood - and the world will bow down to you.

My current desktop
[hsimg]http://i1313.photobucket.com/albums/t559/TweaknFreak/6-22-20149-46-40PM_zps7bcbc1f6.png[/hsimg]
User avatar
thatsIch
Posts: 446
Joined: August 7th, 2012, 9:18 pm

Re: problem in creating analoge date

Post by thatsIch »

There are 2 possible ways:

- do everything hard coded like

Code: Select all

m = { 31, 28, 31, 30, ... }
print(m[currentMonth])
or just take a starttime like

Code: Select all

startTime = os.time{year=2012, month=8, day=1, hour=0}
oneDay = 86400000 (i guess cause 24*60*60*1000)
nextDay = startTime + oneDay
and then format the date with os.date

I prefer the hardcode way, cause its easier to read and understand, though I dont like hard-coded stuff like that
User avatar
Mordasius
Posts: 1173
Joined: January 22nd, 2011, 4:23 pm
Location: GMT +8

Re: problem in creating analoge date

Post by Mordasius »

hack_er4 wrote:but with date I can't able to write the script as every month end the keep on changing.... Is there any way to get those right every month?
If what you want is the number of days in the current month taking account of leap years then you could use something like the following (which is really just an elaboration of thatsIch's 'hardcode' method):

Code: Select all

[mMonth]
Measure=Time
Format=%#m
UpdateDivider=-1

[mYear]
Measure=Time
Format=%Y
UpdateDivider=-1

[mLuaScript]
Measure=Script
ScriptFile=DaysInMonth.lua

[MtDaysThisMonth]
Meter=String
MeasureName=mLuaScript
FontColor=ffffff
FontSize=12
AntiAlias=1
Text="There are %1 days in the current month"
UpdateDivider=-1
DaysInMonth.lua

Code: Select all

function Initialize()
  monthDays = {31,28,31,30,31,30,31,31,30,31,30,31} 
  msMonth = SKIN:GetMeasure('mMonth')
  msYear = SKIN:GetMeasure('mYear')
end -->Initialize

function Update()
    SKIN:Bang('!DisableMeasure mLuaScript') -- script only needs to run once a month
    if leapYear(msYear:GetValue()) then monthDays[2]=29 end  	 -- handles leap years
  return monthDays[msMonth:GetValue()]  -- script returns number of days in the month
end -->Update

function leapYear(y) 
  return ((y%4==0) and not (y%100==0 and not(y%400==0)))
end -->leapYear
hack_er4
Posts: 4
Joined: August 19th, 2012, 6:35 am

Re: problem in creating analoge date

Post by hack_er4 »

Thanks for the help Mordasius and thatsIch

I want them to put on the rotator.
Like this
You do not have the required permissions to view the files attached to this post.
User avatar
MerlinTheRed
Rainmeter Sage
Posts: 889
Joined: September 6th, 2011, 6:34 am

Re: problem in creating analoge date

Post by MerlinTheRed »

That's a different case. If you want to do something like this, it has to skip some days if they are not present in the current month. That's even easier to do. You just program the rotator like each month has 31 days. Then if a month has less days, it will jump e.g. from 28 to 1 at the end of February. No need to adjust anything.
Have more fun creating skins with Sublime Text 2 and the Rainmeter Package!
User avatar
Mordasius
Posts: 1173
Joined: January 22nd, 2011, 4:23 pm
Location: GMT +8

Re: problem in creating analoge date

Post by Mordasius »

hack_er4 wrote:I want them to put on the rotator.
Like this
DSC02624.JPG
Please tell me you want to make an analog clock showing the proportion of total days in the current month passed rather than just show the date from 1-31.
You do not have the required permissions to view the files attached to this post.
hack_er4
Posts: 4
Joined: August 19th, 2012, 6:35 am

Re: problem in creating analoge date

Post by hack_er4 »

MerlinTheRed wrote:That's a different case. If you want to do something like this, it has to skip some days if they are not present in the current month. That's even easier to do. You just program the rotator like each month has 31 days. Then if a month has less days, it will jump e.g. from 28 to 1 at the end of February. No need to adjust anything.
I'll try this.
can You please suggest some code regarding this It will help me alot. thanks :)
hack_er4
Posts: 4
Joined: August 19th, 2012, 6:35 am

Re: problem in creating analoge date

Post by hack_er4 »

Mordasius wrote: Please tell me you want to make an analog clock showing the proportion of total days in the current month passed rather than just show the date from 1-31.
Thanks for asking.,
I just want the "hand" to point on the current date every month.
As MerlinTheRed suggested all month set to 31. If less than 31 then skip to 1.