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,
It is currently May 1st, 2024, 6:40 am
problem in creating analoge date
-
- Posts: 4
- Joined: August 19th, 2012, 6:35 am
-
- Posts: 217
- Joined: July 14th, 2012, 7:26 am
Re: problem in creating analoge date
Check out the code of this. Might be helpful.
http://limpet.deviantart.com/art/Rainmeter-Calendar-106839760
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]
My current desktop
[hsimg]http://i1313.photobucket.com/albums/t559/TweaknFreak/6-22-20149-46-40PM_zps7bcbc1f6.png[/hsimg]
-
- Posts: 446
- Joined: August 7th, 2012, 9:18 pm
Re: problem in creating analoge date
There are 2 possible ways:
- do everything hard coded like
or just take a starttime like
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
- do everything hard coded like
Code: Select all
m = { 31, 28, 31, 30, ... }
print(m[currentMonth])
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
I prefer the hardcode way, cause its easier to read and understand, though I dont like hard-coded stuff like that
Powered by Sublime Text 3 with Rainmeter-Package
-
- Posts: 1173
- Joined: January 22nd, 2011, 4:23 pm
- Location: GMT +8
Re: problem in creating analoge date
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):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?
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
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
-
- Posts: 4
- Joined: August 19th, 2012, 6:35 am
Re: problem in creating analoge date
Thanks for the help Mordasius and thatsIch
I want them to put on the rotator.
Like this
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.
-
- Rainmeter Sage
- Posts: 889
- Joined: September 6th, 2011, 6:34 am
Re: problem in creating analoge date
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!
-
- Posts: 1173
- Joined: January 22nd, 2011, 4:23 pm
- Location: GMT +8
Re: problem in creating analoge date
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.hack_er4 wrote: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.
-
- Posts: 4
- Joined: August 19th, 2012, 6:35 am
Re: problem in creating analoge date
I'll try this.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.
can You please suggest some code regarding this It will help me alot. thanks
-
- Posts: 4
- Joined: August 19th, 2012, 6:35 am
Re: problem in creating analoge date
Thanks for asking.,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.
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.