Here's a formula that actually exploits the TRUE=1 and FALSE=0 logical to numerical equivalence, and using the % modulo to take advantage of the relation between the odd / even month number and their number of days over the course of a year. Scroll to navigate by month:I left the earlier formula (my own from my skin suite, which is very similar to balala's) just to compare the formulas' lengths. Apparently, the modulo trick I thought about and mentioned earlier is not a new idea, others tried the same before, except that the February part wasn't covered there.
Above, the 31-(#Month#-1)%7%2 handles the 31 and 30 alternation for odd months from Jan (month 1) to Jul (month 7) and for even months from Aug (month 8) to Dec (month 12), while the (#Month#=2)*(2-((#Year#%4=0)*(#Year#%100<>0)+(#Year#%400=0))) handles subtracting 1 from 30 for the leap year's Feb and 2 from 30 for the common year's Feb (month 2). All the round bracket enclosed parts from the February handling are implicitly converted to either 0 or 1 numerical values, corresponding to the FALSE or TRUE logical value of the contained conditional test, e.g for Feb 2004 it's 1*(2-(1*1+0)) = 2-1 = 1, for Feb 2100 it's 1*(2-(1*0+0)) = 2-0 = 2, for Feb 2400 it's 1*(2-(1*0+1)) = 2-1 = 1, for Mar 2004 it's 0*(2-(1*1+0)) = 0*(2-1) = 0, which are subtracted from either 30 or 31 depending on the month number. In other words, if in a numerical formula one has (5=5) aka TRUE that would be 1 as a number, and if he has (5=4) aka FALSE that would be 0 as a number.
Code:
[Variables]Year=2025Month=3[Rainmeter]Update=1000AccurateText=1DynamicWindowSize=1---Measures---[Days]Measure=Calc;Formula=((#Month#=1)||(#Month#=3)||(#Month#=5)||(#Month#=7)||(#Month#=8)||(#Month#=10)||(#Month#=12)?31:((#Month#=4)||(#Month#=6)||(#Month#=9)||(#Month#=11)?30:(((#Year#%4=0)&&(#Year#%100<>0))||(#Year#%400=0)?29:28)))Formula=(31-(#Month#-1)%7%2-(#Month#=2)*(2-((#Year#%4=0)*(#Year#%100<>0)+(#Year#%400=0))))DynamicVariables=1---Meters---[Result]Meter=StringSolidColor=0,0,0,128FontColor=255,255,255,255FontFace=ConsolasFontSize=16Padding=5,5,5,5AntiAlias=1MeasureName=DaysText=Year = #Year##CRLF#Month = #Month##CRLF#Days = %1UpdateDivider=-1MouseScrollUpAction=[!SetVariable Year (#Month#=1?#Year#-1:#Year#)][!SetVariable Month (#Month#=1?12:#Month#-1)][!UpdateMeasure *][!UpdateMeter *][!Redraw]MouseScrollDownAction=[!SetVariable Year (#Month#=12?#Year#+1:#Year#)][!SetVariable Month (#Month#=12?1:#Month#+1)][!UpdateMeasure *][!UpdateMeter *][!Redraw]DynamicVariables=1
Above, the 31-(#Month#-1)%7%2 handles the 31 and 30 alternation for odd months from Jan (month 1) to Jul (month 7) and for even months from Aug (month 8) to Dec (month 12), while the (#Month#=2)*(2-((#Year#%4=0)*(#Year#%100<>0)+(#Year#%400=0))) handles subtracting 1 from 30 for the leap year's Feb and 2 from 30 for the common year's Feb (month 2). All the round bracket enclosed parts from the February handling are implicitly converted to either 0 or 1 numerical values, corresponding to the FALSE or TRUE logical value of the contained conditional test, e.g for Feb 2004 it's 1*(2-(1*1+0)) = 2-1 = 1, for Feb 2100 it's 1*(2-(1*0+0)) = 2-0 = 2, for Feb 2400 it's 1*(2-(1*0+1)) = 2-1 = 1, for Mar 2004 it's 0*(2-(1*1+0)) = 0*(2-1) = 0, which are subtracted from either 30 or 31 depending on the month number. In other words, if in a numerical formula one has (5=5) aka TRUE that would be 1 as a number, and if he has (5=4) aka FALSE that would be 0 as a number.
Statistics: Posted by Yincognito — Today, 4:36 am