It is currently May 24th, 2019, 10:09 pm

Assistance with Calculating Term End Dates

Help with creating, editing & fixing problems with skins
Craash
Posts: 24
Joined: October 17th, 2017, 4:37 pm

Assistance with Calculating Term End Dates

Craash » May 17th, 2019, 4:12 pm

I'm a professor at a university, and I use rainmeter for a ton of stuff. Lots of SNMP monitoring of other devices, along with hwifno, plex, etc.

I"m trying to come up with a skin that will show me the following information on student terms: There would be 5 lines, the current term, and the previous 5 terms.


| Current Term (First of Current Month | Term End (Current + 6 MO) | Weeks Left (Term End - Current Month in Weeks) | Critical Action (Current Month +45 - Today)

I'm hoping for the previous 5 terms as line items too, (First Day of current month -1 Month), (First Day of current month -2 Month), etc.

Obviously, i some instances it will roll to the previous year.

I can calculate the previous term start dates, back until it rolls to the previous year, but I'm really not sure how to calculate the other stuff I want. Any ideas?

Code: Select all

[Rainmeter]
Update=1000
AccurateText=1
BackgroundMode=2
SolidColor=255,0,0,0
;*****************************
SkinWidth=171
SkinHeight=200
ContextTitle=Open @Includes Folder
ContextAction=["#@#"]
ContextTitle2=---
ContextAction2=[]
ContextTitle3=More Actions...
ContextAction3=[!SkinMenu]
RightMouseUpAction=!SkinCustomMenu


[Variables]
; Font Variables
TextFont=Fira Sans
MonoFont=Fira Mono

; Color Variables
LabelColor=208,224,247
ValueColor=247,252,255,255
BarBackColor=#LabelColor#,75
BackgroundAlpha=200
BackgroundColor=0,0,0,#BackgroundAlpha#
BackHeight=200

[MeterAllBackground]
Meter=Image
W=170
;H=100
#H=160
SolidColor=0,0,0,1

[MeterNetBackground]
Meter=Shape
;Shape=Rectangle 1,1,169,103,12 | Fill Color #BackgroundColor# | StrokeWidth 1 | Stroke Color #LabelColor#
Shape=Rectangle 1,1,169,160,12 | Fill Color #BackgroundColor# | StrokeWidth 1 | Stroke Color #LabelColor#
;X=(#NetOffSet#)
W=171
;H=103
H=165
UpdateDivider=-1
DynamicVariables=1

[mMonth]
Measure			=time
Format			=%#m

[Month-1]
Measure			=calc
Formula			=mMonth - 1

[Month-2]
Measure			=calc
Formula			=mMonth - 2
[Month-3]
Measure			=calc
Formula			=mMonth - 3
[Month-4]
Measure			=calc
Formula			=mMonth - 4
[Month-5]
Measure			=calc
Formula			=mMonth - 5
[Meter CurrentMonth]
Meter=String
MeasureName=mMonth
X=5
Y=5
W=105
H=17
ClipString=1
SolidColor=0,0,0,1
InlineSetting=Face | #TextFont#
InlineSetting2=Size | 10
InlineSetting3=Color | #ValueColor#,255
AntiAlias=1
DynamicVariables=1
Text=%1/1/19

[Meter MeasureMonth-1]
Meter=String
MeasureName=Month-1
X=5
Y=20r
W=105
H=17
ClipString=1
SolidColor=0,0,0,1
InlineSetting=Face | #TextFont#
InlineSetting2=Size | 10
InlineSetting3=Color | #ValueColor#,255
AntiAlias=1
DynamicVariables=1
Text=%1/1/19

[Meter MeasureMonth-2]
Meter=String
MeasureName=Month-2
X=5
Y=20r
W=105
H=17
ClipString=1
SolidColor=0,0,0,1
InlineSetting=Face | #TextFont#
InlineSetting2=Size | 10
InlineSetting3=Color | #ValueColor#,255
AntiAlias=1
DynamicVariables=1
Text=%1/1/19
[Meter MeasureMonth-3]
Meter=String
MeasureName=Month-3
X=5
Y=20r
W=105
H=17
ClipString=1
SolidColor=0,0,0,1
InlineSetting=Face | #TextFont#
InlineSetting2=Size | 10
InlineSetting3=Color | #ValueColor#,255
AntiAlias=1
DynamicVariables=1
Text=%1/1/19
[Meter MeasureMonth-4]
Meter=String
MeasureName=Month-4
X=5
Y=20r
W=105
H=17
ClipString=1
SolidColor=0,0,0,1
InlineSetting=Face | #TextFont#
InlineSetting2=Size | 10
InlineSetting3=Color | #ValueColor#,255
AntiAlias=1
DynamicVariables=1
Text=%1/1/19
[Meter MeasureMonth-5]
Meter=String
MeasureName=Month-5
X=5
Y=20r
W=105
H=17
ClipString=1
SolidColor=0,0,0,1
InlineSetting=Face | #TextFont#
InlineSetting2=Size | 10
InlineSetting3=Color | #ValueColor#,255
Text=([Month-5] = 0 ? 12 : [Month-5])
AntiAlias=1
DynamicVariables=1
Last edited by eclectic-tech on May 21st, 2019, 12:22 am, edited 1 time in total.
Reason: Please use code tags. It is the </> symbol.
User avatar
SilverAzide
Posts: 555
Joined: March 23rd, 2015, 5:26 pm

Re: Assistance with Calculating Term End Dates

SilverAzide » May 17th, 2019, 8:31 pm

I think you need to clarify what you are trying to do. Your approach of using the "current month" and a time measure doesn't seem like a workable plan. By using "current month", you are going to create a sliding "window" of time, where you will never reach the "term end" date, because it is always 6 months from "now". The other milestones will also never be reached for the same reason.

You need to put a stake in the sand and select the start; once you do that, all other milestone dates can be easily calculated.
DeviantArt Gadgets More...
Craash
Posts: 24
Joined: October 17th, 2017, 4:37 pm

Re: Assistance with Calculating Term End Dates

Craash » May 18th, 2019, 6:50 pm

SilverAzide wrote:
May 17th, 2019, 8:31 pm
I think you need to clarify what you are trying to do. Your approach of using the "current month" and a time measure doesn't seem like a workable plan. By using "current month", you are going to create a sliding "window" of time, where you will never reach the "term end" date, because it is always 6 months from "now". The other milestones will also never be reached for the same reason.

You need to put a stake in the sand and select the start; once you do that, all other milestone dates can be easily calculated.
It IS a rolling windows. We have terms start each month, I want to to know how many weeks are left in the term, along with once 45 days have passed for each term. The 'stake in the sand' is the 1st of the current month.

Each month, the term that is 5 months old will fall off and a new one will start.


This would be for "now" (5.181.19). I didn't do that actual match, just made it close. Next month, 12.1.18 would roll off (because the term is over) and 6.1.19 would be added.

Term Start____ Weeks Left___ Critical Action
12.1.18_________ 2__________Past
1.1.19__________ 6__________Past
2.1.19__________10 _________Past
3.1.19__________14__________Past
4.1.19__________18__________2 days
5.1.19__________22__________30 days

The entire concept is when I speak with a student, I can tell at a glance how many weeks are left in his current term.


John, your term started 2.1.19 - you have 10 weeks left, yet you still have 8 credits to finish.

Mike, your term started 4.1.19, you have 3 days left to finish the critical action (first test).
User avatar
eclectic-tech
Rainmeter Sage
Posts: 3335
Joined: April 12th, 2012, 9:40 pm
Location: Cedar Point, Ohio, USA

Re: Assistance with Calculating Term End Dates

eclectic-tech » May 21st, 2019, 3:47 am

Here is a start to your project. [mTime] returns the timestamp for the current day.
On the first day of a month, the skin will set Term1End and Term1Critical variables.
Those values are used to calculate the remaning weeks and days for all terms as time passes.

I have not fully tested, but this should get you at least a starting point.

Code: Select all

[Rainmeter]
Update=1000
AccurateText=1
BackgroundMode=2
SolidColor=255,0,0,0
;*****************************
SkinWidth=341
SkinHeight=200
ContextTitle=Open @Includes Folder
ContextAction=["#@#"]
ContextTitle2=---
ContextAction2=[]
ContextTitle3=More Actions...
ContextAction3=[!SkinMenu]
RightMouseUpAction=!SkinCustomMenu


[Variables]
; Font Variables
TextFont=Fira Sans
MonoFont=Fira Mono
TextSize=12

; Color Variables
LabelColor=208,224,247
ValueColor=247,252,255,255
BarBackColor=#LabelColor#,75
BackgroundAlpha=200
BackgroundColor=0,0,0,#BackgroundAlpha#
; Positioning
Tab0=5
Tab1=100
Tab2=200

Term1Critical=13204938054
Term1End=13216382871
‬
; ============== Measures ==============
; =====================================

[mTime]
Measure=Time

[mYear]
Measure=Time
Format=%#y

[mPreviousYear]
Measure=Calc
Formula=mYear-1

[mMonth]
Measure=Time
Format=%#m

[PreviousMonth1]
Measure=calc
Formula=((mMonth - 1 + 11) % 12) + 1
IfCondition=(#CurrentSection#>mMonth)
IfTrueAction=[!SetOption MeterPreviousMonth1 MeasureName2 "mPreviousYear"]
IfFalseAction=[!SetOption MeterPreviousMonth1 MeasureName2 "mYear"]

[PreviousMonth2]
Measure=calc
Formula=((mMonth - 2 + 11) % 12) + 1
IfCondition=(#CurrentSection#>mMonth)
IfTrueAction=[!SetOption MeterPreviousMonth2 MeasureName2 "mPreviousYear"]
IfFalseAction=[!SetOption MeterPreviousMonth2 MeasureName2 "mYear"]

[PreviousMonth3]
Measure=calc
Formula=((mMonth - 3 + 11) % 12) + 1
IfCondition=(#CurrentSection#>mMonth)
IfTrueAction=[!SetOption MeterPreviousMonth3 MeasureName2 "mPreviousYear"]
IfFalseAction=[!SetOption MeterPreviousMonth3 MeasureName2 "mYear"]

[PreviousMonth4]
Measure=calc
Formula=((mMonth - 4 + 11) % 12) + 1
IfCondition=(#CurrentSection#>mMonth)
IfTrueAction=[!SetOption MeterPreviousMonth4 MeasureName2 "mPreviousYear"]
IfFalseAction=[!SetOption MeterPreviousMonth4 MeasureName2 "mYear"]

[PreviousMonth5]
Measure=calc
Formula=((mMonth - 5 + 11) % 12) + 1
IfCondition=(#CurrentSection#>mMonth)
IfTrueAction=[!SetOption MeterPreviousMonth5 MeasureName2 "mPreviousYear"]
IfFalseAction=[!SetOption MeterPreviousMonth5 MeasureName2 "mYear"]

[mDay]
Measure=Time
Format=%#d
; Actions to create a new term, delete oldest term and set 45 day point
IfCondition=(#CurrentSection#=1)
IfTrueAction=[!EnableMeasureGroup NewTerm][!UpdateMeasureGroup NewTerm][!DisableMeasureGroup NewTerm]

[mTerm1Plus45Days]
Group=NewTerm
Measure=Calc
Formula=mTime + (45 * 86400)
OnUpdateAction=[!SetVariable Term1Critical [mTerm1Plus45Days]][!WriteKeyValue Variables Term1Critical [mTerm1Plus45Days]]
Disabled=1

[mTerm1CriticalDaysRemaining]
Measure=Calc
Formula=Round((#Term1Critical# - mTime)/86400)

[mPreviousTermCritical]
Measure=Calc
Formula=Clamp(mTerm1CriticalDaysRemaining - 30,0,15)
DynamicVariables=1

[mTerm1End]
Group=NewTerm
Measure=Calc
Formula=mTime + 24 * 604800
OnUpdateAction=[!SetVariable Term1End [mTerm1End]][!WriteKeyValue Variables Term1End [mTerm1End]]
Disabled=1

[mTerm1WeeksRemaining]
Measure=Calc
Formula=Round((#Term1End# - mTime)/604800)

[mTerm2WeeksRemaining]
Measure=Calc
Formula=Clamp(mTerm1WeeksRemaining - 4,0,22)

[mTerm3WeeksRemaining]
Measure=Calc
Formula=Clamp(mTerm1WeeksRemaining - 8,0,22)

[mTerm4WeeksRemaining]
Measure=Calc
Formula=Clamp(mTerm1WeeksRemaining - 12,0,22)

[mTerm5WeeksRemaining]
Measure=Calc
Formula=Clamp(mTerm1WeeksRemaining - 16,0,22)

[mTerm6WeeksRemaining]
Measure=Calc
Formula=Clamp(mTerm1WeeksRemaining - 20,0,22)


; Meters
; =====================================

[MeterNetBackground]
Meter=Shape
;Shape=Rectangle 1,1,169,103,12 | Fill Color #BackgroundColor# | StrokeWidth 1 | Stroke Color #LabelColor#
Shape=Rectangle 1,1,310,150,12 | Fill Color #BackgroundColor# | StrokeWidth 1 | Stroke Color #LabelColor#
;X=(#NetOffSet#)
UpdateDivider=-1
DynamicVariables=1

;Term Start____ Weeks Left___ Critical Action
[MeterTitle1]
Meter=String
X=#Tab0#
Y=5
W=100
H=17
ClipString=1
SolidColor=0,0,0,1
InlineSetting=Face | #TextFont#
InlineSetting2=Size | #TextSize#
InlineSetting3=Color | #ValueColor#,255
AntiAlias=1
DynamicVariables=1
Text=Term Start

[MeterTitle2]
Meter=String
X=#Tab1#
Y=5
W=100
H=17
ClipString=1
SolidColor=0,0,0,1
InlineSetting=Face | #TextFont#
InlineSetting2=Size | #TextSize#
InlineSetting3=Color | #ValueColor#,255
AntiAlias=1
DynamicVariables=1
Text=Weeks Left

[MeterTitle3]
Meter=String
X=#Tab2#
Y=5
W=100
H=17
ClipString=1
SolidColor=0,0,0,1
InlineSetting=Face | #TextFont#
InlineSetting2=Size | #TextSize#
InlineSetting3=Color | #ValueColor#,255
AntiAlias=1
DynamicVariables=1
Text=Critical Action

[MeterPreviousMonth5]
Meter=String
MeasureName=PreviousMonth5
MeasureName2=mYear
X=#Tab0#
Y=20r
W=100
H=17
ClipString=1
SolidColor=0,0,0,1
InlineSetting=Face | #TextFont#
InlineSetting2=Size | #TextSize#
InlineSetting3=Color | #ValueColor#,255
Text=%1/1/%2
AntiAlias=1
DynamicVariables=1

[MeterPreviousMonth5WeeksLeft]
Meter=String
MeasureName=mTerm6WeeksRemaining
X=(#Tab1#+45)
Y=r
W=100
H=17
StringAlign=Center
ClipString=1
SolidColor=0,0,0,1
InlineSetting=Face | #TextFont#
InlineSetting2=Size | #TextSize#
InlineSetting3=Color | #ValueColor#,255
Text=%1
AntiAlias=1
DynamicVariables=1

[MeterPreviousMonth5Critical]
Meter=String
X=(#Tab2#+45)
Y=r
W=100
H=17
StringAlign=Center
ClipString=1
SolidColor=0,0,0,1
InlineSetting=Face | #TextFont#
InlineSetting2=Size | #TextSize#
InlineSetting3=Color | #ValueColor#,255
Text=Past
AntiAlias=1
DynamicVariables=1

[MeterPreviousMonth4]
Meter=String
MeasureName=PreviousMonth4
MeasureName2=mYear
X=5
Y=20r
W=105
H=17
ClipString=1
SolidColor=0,0,0,1
InlineSetting=Face | #TextFont#
InlineSetting2=Size | #TextSize#
InlineSetting3=Color | #ValueColor#,255
AntiAlias=1
DynamicVariables=1
Text=%1/1/%2

[MeterPreviousMonth4WeeksLeft]
Meter=String
MeasureName=mTerm5WeeksRemaining
X=(#Tab1#+45)
Y=r
W=100
H=17
StringAlign=Center
ClipString=1
SolidColor=0,0,0,1
InlineSetting=Face | #TextFont#
InlineSetting2=Size | #TextSize#
InlineSetting3=Color | #ValueColor#,255
Text=%1
AntiAlias=1
DynamicVariables=1

[MeterPreviousMonth4Critical]
Meter=String
X=(#Tab2#+45)
Y=r
W=100
H=17
StringAlign=Center
ClipString=1
SolidColor=0,0,0,1
InlineSetting=Face | #TextFont#
InlineSetting2=Size | #TextSize#
InlineSetting3=Color | #ValueColor#,255
Text=Past
AntiAlias=1
DynamicVariables=1

[MeterPreviousMonth3]
Meter=String
MeasureName=PreviousMonth3
MeasureName2=mYear
X=5
Y=20r
W=105
H=17
ClipString=1
SolidColor=0,0,0,1
InlineSetting=Face | #TextFont#
InlineSetting2=Size | #TextSize#
InlineSetting3=Color | #ValueColor#,255
AntiAlias=1
DynamicVariables=1
Text=%1/1/%2

[MeterPreviousMonth3WeeksLeft]
Meter=String
MeasureName=mTerm4WeeksRemaining
X=(#Tab1#+45)
Y=r
W=100
H=17
StringAlign=Center
ClipString=1
SolidColor=0,0,0,1
InlineSetting=Face | #TextFont#
InlineSetting2=Size | #TextSize#
InlineSetting3=Color | #ValueColor#,255
Text=%1
AntiAlias=1
DynamicVariables=1

[MeterPreviousMonth3Critical]
Meter=String
X=(#Tab2#+45)
Y=r
W=100
H=17
StringAlign=Center
ClipString=1
SolidColor=0,0,0,1
InlineSetting=Face | #TextFont#
InlineSetting2=Size | #TextSize#
InlineSetting3=Color | #ValueColor#,255
Text=Past
AntiAlias=1
DynamicVariables=1

[MeterPreviousMonth2]
Meter=String
MeasureName=PreviousMonth2
MeasureName2=mYear
X=5
Y=20r
W=105
H=17
ClipString=1
SolidColor=0,0,0,1
InlineSetting=Face | #TextFont#
InlineSetting2=Size | #TextSize#
InlineSetting3=Color | #ValueColor#,255
AntiAlias=1
DynamicVariables=1
Text=%1/1/%2

[MeterPreviousMonth2WeeksLeft]
Meter=String
MeasureName=mTerm3WeeksRemaining
X=(#Tab1#+45)
Y=r
W=100
H=17
StringAlign=Center
ClipString=1
SolidColor=0,0,0,1
InlineSetting=Face | #TextFont#
InlineSetting2=Size | #TextSize#
InlineSetting3=Color | #ValueColor#,255
Text=%1
AntiAlias=1
DynamicVariables=1

[MeterPreviousMonth2Critical]
Meter=String
X=(#Tab2#+45)
Y=r
W=100
H=17
StringAlign=Center
ClipString=1
SolidColor=0,0,0,1
InlineSetting=Face | #TextFont#
InlineSetting2=Size | #TextSize#
InlineSetting3=Color | #ValueColor#,255
Text=Past
AntiAlias=1
DynamicVariables=1

[MeterPreviousMonth1]
Meter=String
MeasureName=PreviousMonth1
MeasureName2=mYear
X=5
Y=20r
W=105
H=17
ClipString=1
SolidColor=0,0,0,1
InlineSetting=Face | #TextFont#
InlineSetting2=Size | #TextSize#
InlineSetting3=Color | #ValueColor#,255
AntiAlias=1
DynamicVariables=1
Text=%1/1/%2

[MeterPreviousMonth1WeeksLeft]
Meter=String
MeasureName=mTerm2WeeksRemaining
X=(#Tab1#+45)
Y=r
W=100
H=17
StringAlign=Center
ClipString=1
SolidColor=0,0,0,1
InlineSetting=Face | #TextFont#
InlineSetting2=Size | #TextSize#
InlineSetting3=Color | #ValueColor#,255
Text=%1
AntiAlias=1
DynamicVariables=1

[MeterPreviousMonth1Critical]
Meter=String
MeasureName=mPreviousTermCritical
X=(#Tab2#+45)
Y=r
W=100
H=17
StringAlign=Center
ClipString=1
SolidColor=0,0,0,1
InlineSetting=Face | #TextFont#
InlineSetting2=Size | #TextSize#
InlineSetting3=Color | #ValueColor#,255
Text=%1
AntiAlias=1
DynamicVariables=1

[MeterCurrentMonth]
Meter=String
MeasureName=mMonth
MeasureName2=mYear
X=5
Y=20r
W=105
H=17
ClipString=1
SolidColor=0,0,0,1
InlineSetting=Face | #TextFont#
InlineSetting2=Size | #TextSize#
InlineSetting3=Color | #ValueColor#,255
AntiAlias=1
DynamicVariables=1
Text=%1/1/%2

[MeterCurrentMonthWeeksRemaining]
Meter=String
MeasureName=mTerm1WeeksRemaining
X=(#Tab1#+45)
Y=r
W=100
H=17
StringAlign=Center
ClipString=1
SolidColor=0,0,0,1
InlineSetting=Face | #TextFont#
InlineSetting2=Size | #TextSize#
InlineSetting3=Color | #ValueColor#,255
Text=%1
AntiAlias=1
DynamicVariables=1

[MeterCurrentMonthCritical]
Meter=String
MeasureName=mTerm1CriticalDaysRemaining
X=(#Tab2#+45)
Y=r
W=100
H=17
StringAlign=Center
ClipString=1
SolidColor=0,0,0,1
InlineSetting=Face | #TextFont#
InlineSetting2=Size | #TextSize#
InlineSetting3=Color | #ValueColor#,255
Text=%1
AntiAlias=1
DynamicVariables=1

terms.png
EDIT: JSMorley posted a tip regarding working with time and date calculations using a Lua script. I highly recommend looking at his approach when calculating elapsed time.
You do not have the required permissions to view the files attached to this post.
Craash
Posts: 24
Joined: October 17th, 2017, 4:37 pm

Re: Assistance with Calculating Term End Dates

Craash » May 22nd, 2019, 4:29 pm

This is EXACTLY what I was hoping for. The critical actions days are a few days off, but enough to get me in the ballpark. Thank you so much!

Image
User avatar
eclectic-tech
Rainmeter Sage
Posts: 3335
Joined: April 12th, 2012, 9:40 pm
Location: Cedar Point, Ohio, USA

Re: Assistance with Calculating Term End Dates

eclectic-tech » Yesterday, 12:43 am

Happy to help!