It is currently March 28th, 2024, 6:51 pm

Test if registry date is over 2 weeks old

Get help with creating, editing & fixing problems with skins
BigBadRob
Posts: 2
Joined: June 3rd, 2018, 9:55 am

Test if registry date is over 2 weeks old

Post by BigBadRob »

Hi,
I am trying to compare a date read from the registry to see if it is older than 2 weeks (to see if my antivirus is out of date)
At the moment I just read it and then switch it around to UK style, what I would like is to change the font colour to red if that date is greater than 2 weeks from the current date.

Code: Select all

[measureDATDate]
Measure=Registry
RegHKey=HKEY_LOCAL_MACHINE
RegKey=SOFTWARE\McAfee\AVEngine
RegValue=AVDatDate
;Update every 10 minutes
UpdateDivider=600
;re-arrange date to british format of day month year
RegExpSubstitute=1
Substitute="(\w+)/(\w+)/(\w+)":"\3/\2/\1"

; ###################################################################################

[meterLabelDATDate]
Meter=String
MeterStyle=styleLeftText
X=10
Y=100
W=275
H=14
Text=DAT Date

[meterValueDATDate]
Meter=String
MeterStyle=styleRightText
MeasureName=measureDATDate
X=270
Y=0r
W=275
H=14
Text=%1
Thanks.
Last edited by BigBadRob on June 4th, 2018, 10:24 am, edited 1 time in total.
User avatar
eclectic-tech
Rainmeter Sage
Posts: 5382
Joined: April 12th, 2012, 9:40 pm
Location: Cedar Point, Ohio, USA

Re: Test if registry date is over 2 weeks old

Post by eclectic-tech »

I would create a TimeStamp measure based on the information returned by your [measureDATDate], but you need to know exactly what format the day, month, and year returned by that measure in order to create TimeStampFormat...

Are there preceding zeroes for the days or months?
Is the year 2 digit or a full 4 digit?

With that information, you could create a TimeStamp value of the returned date for comparison to a Time measure of today's date.

The code below will change the background to red if the difference is over 2 weeks.

You may need to modify the TimeStampFormat= to match the values returned by your AV date.
I substituted my own date if the measure returned '0' ; which it does since I do not have that software.

Code: Select all

[measureDATDate]
Measure=Registry
RegHKey=HKEY_LOCAL_MACHINE
RegKey=SOFTWARE\McAfee\AVEngine
RegValue=AVDatDate
;Update every 10 minutes
UpdateDivider=600
;re-arrange date to british format of day month year
RegExpSubstitute=1
Substitute="(\w+)/(\w+)/(\w+)":"\3/\2/\1T00:00:00","0":"25/05/2018T00:00:00"

; 2 weeks in seconds = 1209600 seconds
[MeasureCurrentTime]
Measure=Time

[MeasureDATDateSeconds]
Measure=Time
TimeStamp=[&measureDATDate]
TimeStampFormat=%d/%m/%YT%H:%M:%S
IfCondition=(MeasureCurrentTime - MeasureDATDateSeconds >= 1209600)
IfTrueAction=[!SetVariable BackgroundColor "255,0,0,100"][!UpdateMeter *][!Redraw]
IfFalseAction=[!SetVariable BackgroundColor "255,255,255,100"][!UpdateMeter *][!Redraw]

; ###################################################################################

[meterLabelDATDate]
Meter=String
MeterStyle=styleLeftText
X=10
Y=100
W=275
H=14
Text=DAT Date
SolidColor=#BackgroundColor#
DynamicVariables=1

[meterValueDATDate]
Meter=String
MeterStyle=styleRightText
MeasureName=measureDATDate
X=R
Y=0r
W=275
H=14
Text=%1
SolidColor=#BackgroundColor#
DynamicVariables=1
BigBadRob
Posts: 2
Joined: June 3rd, 2018, 9:55 am

Re: Test if registry date is over 2 weeks old

Post by BigBadRob »

Thanks !

Yeah, had to tweak the TimeStampFormat to match the McAfee date %d/%m/%Y but all working.
Looks really good, I was just going to change the text colour but the SolidColor looks cool.
I also left the substitute as it was because that only affected the string displayed, not the calculation.

Code: Select all

[measureDATDate]
Measure=Registry
RegHKey=HKEY_LOCAL_MACHINE
RegKey=SOFTWARE\McAfee\AVEngine
RegValue=AVDatDate
UpdateDivider=600
;re-arrange date to british format of day month year
RegExpSubstitute=1
Substitute="(\w+)/(\w+)/(\w+)":"\3/\2/\1"

[measureCurrentTime]
Measure=Time

[measureDatDateTest]
;Test to see if xDAT is over two weeks old (1209600 seconds)
;if it is make the background colour red, otherwise leave transparent
Measure=Time
TimeStamp=[&measureDATDate]
TimeStampFormat=%d/%m/%Y
IfCondition=(measureCurrentTime - measureDATDateTest >= 1209600)
IfTrueAction=[!SetVariable BackgroundColour "255,0,0,100"]["!UpdateMeter *][!Redraw]
IfFalseAction=[!SetVariable BackgroundColour "0,0,0,1"]["!UpdateMeter *][!Redraw]
DynamicVariables=1

; ###################################################################################

[meterLabelDATDate]
Meter=String
MeterStyle=styleLeftText
X=10
Y=100
W=260
H=14
Text=DAT Date
SolidColor=#BackgroundColour#
DynamicVariables=1

[meterValueDATDate]
Meter=String
MeterStyle=styleRightText
MeasureName=measureDATDate
X=270
Y=0r
W=260
H=14
Text=%1
SolidColor=#BackgroundColour#
DynamicVariables=1