It is currently April 19th, 2024, 10:00 pm

Calendar is off by one day

Get help with creating, editing & fixing problems with skins
dodicci
Posts: 2
Joined: May 2nd, 2022, 10:52 pm

Calendar is off by one day

Post by dodicci »

Hello!

I got an issue with a calendar skin with some months of the year, it doesn't calculate well the previous month number of days.

On the pic April finishes on 31 instead of 30 and the rest of the current month is off by one day.

Image

I searched the forum and found this post with the same issue and same code. The user @Alex2539 fixed the code but it's so old I can't download the file anymore, and even with his great explanations I can't fix it myself...

This is an extract of the code with all the calculation:

Code: Select all

;----Caculation Part----
[cShowOtherMonths]
Measure=Calc
Formula=(#ShowOtherMonths# = 1) ? 1 : 0

[cLeapYear]
Measure=Calc
Formula=((mYear%4 = 0) && (mYear%100 <> 0) || (mYear%400 = 0)) ? 1 : 0

[cPrevMonth]
Measure=calc
Formula=mMonth - 1

[cDayCount]
Measure=Calc
Formula=((mMonth = 4) || (mMonth = 6) || (mMonth = 9) || (mMonth = 11)) ? 30 : ((mMonth = 2) ? ((cLeapYear = 1)  ? 29 : 28) : 31)

[cPrevDayCount]
Measure=Calc
Formula=((cPrevMonth = 4) || (cPrevMonth = 6) || (cPrevMonth = 9) || (cPrevMonth = 11)) ? 30 : ((cPrevMonth = 2) ? ((cLeapYear = 1)  ? 29 : 28) : 31)

[StartDay]
Measure=Calc
Formula= ((mWeekCode + 1) - (mDay % 7)) < 0 ? (mWeekCode + 8 - (mDay % 7)) : (mWeekCode + 1) - (mDay % 7)

;----Day Part Draw----
;----1Line----
;------------------------------
              1a
;------------------------------
[Val11]
Measure=Calc
Formula=(mDay = 1) && (mWeekCode = 0) ? 1 : (cPrevDayCount - StartDay + 1)

[Select11]
Measure=Calc
Formula=((Val11 = mDay) && (Val11 < 8)) ? 1 : ((Val11 > 8) ? -1 : 0)
IfAboveValue=0
IfAboveAction=!Execute [!RainmeterShowMeter H1Line1][!RainmeterHideMeter 1Line1][!RainmeterHideMeter P1Line1]
IfEqualValue=0
IfEqualAction=!Execute [!RainmeterShowMeter 1Line1][!RainmeterHideMeter H1Line1][!RainmeterHideMeter P1Line1]
IfBelowValue=0
IfBelowAction=!Execute [!RainmeterShowMeter P1Line1][!RainmeterHideMeter 1Line1][!RainmeterHideMeter H1Line1]

;--------------------------------
               2a
;--------------------------------
[Val12]
Measure=Calc
Formula=(Val11 < cPrevDayCount) ? (Val11 + 1) : 1

[Select12]
Measure=Calc
Formula=((Val12 = mDay) && (Val12 < 8)) ? 1 : ((Val12 > 8) ? -1 : 0)
IfAboveValue=0
IfAboveAction=!Execute [!RainmeterShowMeter H1Line2][!RainmeterHideMeter 1Line2][!RainmeterHideMeter P1Line2]
IfEqualValue=0
IfEqualAction=!Execute [!RainmeterShowMeter 1Line2][!RainmeterHideMeter H1Line2][!RainmeterHideMeter P1Line2]
IfBelowValue=0
IfBelowAction=!Execute [!RainmeterShowMeter P1Line2][!RainmeterHideMeter 1Line2][!RainmeterHideMeter H1Line2]

...
Thank you for your help.
User avatar
balala
Rainmeter Sage
Posts: 16147
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Calendar is off by one day

Post by balala »

dodicci wrote: May 3rd, 2022, 4:49 pm This is an extract of the code with all the calculation:
The posted piece of code is not enough at all. Post please the whole code. If there are included resources (images most probably), pack the config and upload the package. Or post a link where we can download the skin, please.
dodicci
Posts: 2
Joined: May 2nd, 2022, 10:52 pm

Re: Calendar is off by one day

Post by dodicci »

balala wrote: May 3rd, 2022, 8:10 pm The posted piece of code is not enough at all. Post please the whole code. If there are included resources (images most probably), pack the config and upload the package. Or post a link where we can download the skin, please.
Here is the package.
You do not have the required permissions to view the files attached to this post.