MaestroSky wrote: ↑June 8th, 2021, 8:41 pmFaced with such a problem when I increased the number from 3 to 5 and translated all this time from UNIX to Windows does not translate 3 point.
This might be because you forgot to add the new measures / meters to the
WOTGroup groups. Those are updated each time the
[WOT] WebParser measure is interrogating the source URL (see its
FinishAction). It could be another reason as well, although I can't think of one, not having the whole code in front of me (the code you captured in the screenhot seems fine though). Anyway, for me it works, see below.
MaestroSky wrote: ↑June 8th, 2021, 8:41 pmI also tried to make a real-time check that would filter out the time that has already passed from the list and show the closest to the current time.
So, you want to get the closest time AFTER the current time, right? You know, since the times before the current time are all excluded, and only the closest remains from those times which are after the current time, if I understood correctly. Check this out (local test in my case, you know the system):
Test_1.0.0.rmskin
Code: Select all
[Variables]
WOTIndex=5
Item=(?(?=.*\{).*\{"attack_type":.*,"front_id":".*","front_name":".*","competitor_id":.*,"time":(.*),"vehicle_level":.*,"province_id":".*","type":".*","province_name":".*"\},?)
WOTRegEx=(?siU)^.*\{"status":.*,"meta":\{"(?:quantity|count)":(.*)\},"data":\[#Item##Item##Item##Item##Item#\]\}.*$
MinTimeDifference=9223372036854775807
ClosestToCurrentTimeIndex=0
[Rainmeter]
Update=1000
DynamicWindowSize=1
AccurateText=1
BackgroundMode=2
SolidColor=47,47,47,255
---Measures---
[MeasureUnixTimeStart]
Measure=Time
TimeStamp=03:00:00 01/01/1970
TimeStampFormat=%H:%M:%S %d/%m/%Y
FormatLocale=Local
UpdateDivider=-1
DynamicVariables=1
[CurrentTime]
Measure=Time
Format=%H:%M:%S %d/%m/%Y
FormatLocale=Local
OnUpdateAction=[!SetVariable MinTimeDifference 9223372036854775807]
[WOT]
Measure=WebParser
URL="file://#@#WOT#WOTIndex#.txt"
CodePage=1200
RegExp="#WOTRegEx#"
LogSubstringErrors=0
FinishAction=[!UpdateMeasureGroup WOTGroup][!UpdateMeterGroup WOTGroup][!Redraw]
OnConnectErrorAction=[!UpdateMeasureGroup WOTGroup][!UpdateMeterGroup WOTGroup][!Redraw]
OnRegExpErrorAction=[!UpdateMeasureGroup WOTGroup][!UpdateMeterGroup WOTGroup][!Redraw]
UpdateRate=-1
DynamicVariables=1
[Count]
Group=WOTGroup
Measure=WebParser
URL=[WOT]
StringIndex=1
UpdateDivider=-1
DynamicVariables=1
[Time1]
Group=WOTGroup
Measure=WebParser
URL=[WOT]
StringIndex=2
UpdateDivider=-1
DynamicVariables=1
[Time2]
Group=WOTGroup
Measure=WebParser
URL=[WOT]
StringIndex=3
UpdateDivider=-1
DynamicVariables=1
[Time3]
Group=WOTGroup
Measure=WebParser
URL=[WOT]
StringIndex=4
UpdateDivider=-1
DynamicVariables=1
[Time4]
Group=WOTGroup
Measure=WebParser
URL=[WOT]
StringIndex=5
UpdateDivider=-1
DynamicVariables=1
[Time5]
Group=WOTGroup
Measure=WebParser
URL=[WOT]
StringIndex=6
UpdateDivider=-1
DynamicVariables=1
[WindowsTime1]
Group=WOTGroup
Measure=Calc
Formula=([Time1:Timestamp]+[MeasureUnixTimeStart:Timestamp])
IfCondition=((Abs([CurrentTime:Timestamp]-[WindowsTime1:Timestamp]))<#MinTimeDifference#) && ([WindowsTime1:Timestamp]>=[CurrentTime:Timestamp])
IfTrueAction=[!SetVariable ClosestToCurrentTimeIndex 1][!SetVariable MinTimeDifference (Abs([CurrentTime:Timestamp]-[WindowsTime1:Timestamp]))]
IfConditionMode=1
DynamicVariables=1
[MeasureTimeConvert1]
Group=WOTGroup
Measure=Time
TimeStamp=[WindowsTime1]
FormatLocale=Local
Format=%H:%M:%S %d/%m/%Y
RegExpSubstitute=1
Substitute="^03:00:00 01\/01\/1970$":"None"
DynamicVariables=1
[WindowsTime2]
Group=WOTGroup
Measure=Calc
Formula=([Time2:Timestamp]+[MeasureUnixTimeStart:Timestamp])
IfCondition=((Abs([CurrentTime:Timestamp]-[WindowsTime2:Timestamp]))<#MinTimeDifference#) && ([WindowsTime2:Timestamp]>=[CurrentTime:Timestamp])
IfTrueAction=[!SetVariable ClosestToCurrentTimeIndex 2][!SetVariable MinTimeDifference (Abs([CurrentTime:Timestamp]-[WindowsTime2:Timestamp]))]
IfConditionMode=1
DynamicVariables=1
[MeasureTimeConvert2]
Group=WOTGroup
Measure=Time
TimeStamp=[WindowsTime2]
FormatLocale=Local
Format=%H:%M:%S %d/%m/%Y
RegExpSubstitute=1
Substitute="^03:00:00 01\/01\/1970$":"None"
DynamicVariables=1
[WindowsTime3]
Group=WOTGroup
Measure=Calc
Formula=([Time3:Timestamp]+[MeasureUnixTimeStart:Timestamp])
IfCondition=((Abs([CurrentTime:Timestamp]-[WindowsTime3:Timestamp]))<#MinTimeDifference#) && ([WindowsTime3:Timestamp]>=[CurrentTime:Timestamp])
IfTrueAction=[!SetVariable ClosestToCurrentTimeIndex 3][!SetVariable MinTimeDifference (Abs([CurrentTime:Timestamp]-[WindowsTime3:Timestamp]))]
IfConditionMode=1
DynamicVariables=1
[MeasureTimeConvert3]
Group=WOTGroup
Measure=Time
TimeStamp=[WindowsTime3]
FormatLocale=Local
Format=%H:%M:%S %d/%m/%Y
RegExpSubstitute=1
Substitute="^03:00:00 01\/01\/1970$":"None"
DynamicVariables=1
[WindowsTime4]
Group=WOTGroup
Measure=Calc
Formula=([Time4:Timestamp]+[MeasureUnixTimeStart:Timestamp])
IfCondition=((Abs([CurrentTime:Timestamp]-[WindowsTime4:Timestamp]))<#MinTimeDifference#) && ([WindowsTime4:Timestamp]>=[CurrentTime:Timestamp])
IfTrueAction=[!SetVariable ClosestToCurrentTimeIndex 4][!SetVariable MinTimeDifference (Abs([CurrentTime:Timestamp]-[WindowsTime4:Timestamp]))]
IfConditionMode=1
DynamicVariables=1
[MeasureTimeConvert4]
Group=WOTGroup
Measure=Time
TimeStamp=[WindowsTime4]
FormatLocale=Local
Format=%H:%M:%S %d/%m/%Y
RegExpSubstitute=1
Substitute="^03:00:00 01\/01\/1970$":"None"
DynamicVariables=1
[WindowsTime5]
Group=WOTGroup
Measure=Calc
Formula=([Time5:Timestamp]+[MeasureUnixTimeStart:Timestamp])
IfCondition=((Abs([CurrentTime:Timestamp]-[WindowsTime5:Timestamp]))<#MinTimeDifference#) && ([WindowsTime5:Timestamp]>=[CurrentTime:Timestamp])
IfTrueAction=[!SetVariable ClosestToCurrentTimeIndex 5][!SetVariable MinTimeDifference (Abs([CurrentTime:Timestamp]-[WindowsTime5:Timestamp]))]
IfConditionMode=1
DynamicVariables=1
[MeasureTimeConvert5]
Group=WOTGroup
Measure=Time
TimeStamp=[WindowsTime5]
FormatLocale=Local
Format=%H:%M:%S %d/%m/%Y
RegExpSubstitute=1
Substitute="^03:00:00 01\/01\/1970$":"None"
DynamicVariables=1
[MeasureTimeConvert0]
Group=WOTGroup
Measure=String
String="None"
[MinTimeDifferenceConvert]
Group=WOTGroup
Measure=UpTime
SecondsValue=#MinTimeDifference#
Format="%4!i!d %3!i!h %2!i!m %1!i!s"
RegExpSubstitute=1
Substitute="^579025220d 15h 30m 8s$":"None"
DynamicVariables=1
---Meters---
[CountText]
Group=WOTGroup
Meter=String
FontFace=Consolas
FontColor=255,255,255,255
SolidColor=47,47,47,255
Padding=5,5,5,5
FontSize=16
AntiAlias=1
MeasureName=Count
Text="Count: %1"
UpdateDivider=-1
DynamicVariables=1
[TimeConvert1Text]
Group=WOTGroup
Meter=String
Y=0R
FontFace=Consolas
FontColor=255,255,255,255
SolidColor=47,47,47,255
Padding=5,5,5,5
FontSize=16
AntiAlias=1
MeasureName=MeasureTimeConvert1
Text="Time1: %1"
UpdateDivider=-1
DynamicVariables=1
[TimeConvert2Text]
Group=WOTGroup
Meter=String
Y=0R
FontFace=Consolas
FontColor=255,255,255,255
SolidColor=47,47,47,255
Padding=5,5,5,5
FontSize=16
AntiAlias=1
MeasureName=MeasureTimeConvert2
Text="Time2: %1"
UpdateDivider=-1
DynamicVariables=1
[TimeConvert3Text]
Group=WOTGroup
Meter=String
Y=0R
FontFace=Consolas
FontColor=255,255,255,255
SolidColor=47,47,47,255
Padding=5,5,5,5
FontSize=16
AntiAlias=1
MeasureName=MeasureTimeConvert3
Text="Time3: %1"
UpdateDivider=-1
DynamicVariables=1
[TimeConvert4Text]
Group=WOTGroup
Meter=String
Y=0R
FontFace=Consolas
FontColor=255,255,255,255
SolidColor=47,47,47,255
Padding=5,5,5,5
FontSize=16
AntiAlias=1
MeasureName=MeasureTimeConvert4
Text="Time4: %1"
UpdateDivider=-1
DynamicVariables=1
[TimeConvert5Text]
Group=WOTGroup
Meter=String
Y=0R
FontFace=Consolas
FontColor=255,255,255,255
SolidColor=47,47,47,255
Padding=5,5,5,5
FontSize=16
AntiAlias=1
MeasureName=MeasureTimeConvert5
Text="Time5: %1"
UpdateDivider=-1
DynamicVariables=1
[ClosestToCurrentTimeText]
Group=WOTGroup
Meter=String
Y=10R
FontFace=Consolas
FontColor=255,255,255,255
SolidColor=47,47,47,255
Padding=5,5,5,5
FontSize=16
AntiAlias=1
MeasureName=MeasureTimeConvert#ClosestToCurrentTimeIndex#
MeasureName2=MinTimeDifferenceConvert
Text="Closest After Current Time#CRLF# Item: #ClosestToCurrentTimeIndex##CRLF# Time: %1#CRLF# Diff: %2"
DynamicVariables=1
What I did was:
- add a very large
MinTimeDifference variable (maximum of INT64 value used), initialized every time the
[CurrentTime] measure (see below) updates, so that on querying the source URL, it is always bigger than the absolute value of the difference between the current time and a time of our choosing (e.g.
[WindowsTime1],
[WindowsTime2],
[WindowsTime3] and so on)
- add a
ClosestToCurrentTimeIndex variable where we would store the "index" of the item / measure whose time is the closest after the current time, or 0 if no such measure qualifies
- add a
[CurrentTime] measure holding the current time, which we can then use in computing time related stuff
- add a condition in each
[WindowsTime...] measure to test if that time is the closest after the current time, by comparing to the
MinTimeDifference variable (this will always store the current minimum time difference, so when we found a "new" minimum we update this variable accordingly, along with the "index" of the measure on which we found the said minimum)
- add some RegExp Substitutes to handle the "error" or "none" cases in various measures (including the dummy
[MeasureTimeConvert0] measure to avoid the error in the final
[ClosestToCurrentTimeText] meter when the "index" above has the default / none value of 0)
- add a
[MinTimeDifferenceConvert] Uptime measure to optionally display the actual minimum difference in a readable fashion, if it exists
- finally, add the
[ClosestToCurrentTimeText] meter to display the result, using the "index" I mentioned earlier to associate the proper measure to this meter in
MeasureName
The result (the 3rd time works, as you can see; in the upper right corner is one of my skins showing the current time, to check the math):
Closest After Current Time.jpg
Hopefully I understood what you wanted properly. I attached the packed skin because it was easier than adding the contents of every
WOT....txt mini file that I used in my local tests.
P.S. If I only wanted to get the minimum time difference between the current time and the other time measures in your skin, I could have easily used the
Min() formula method
mentioned by death.crafter in the related thread and forget about using an up to date
MinTimeDifference variable and
IfConditions in every time measure, but I wanted to store the item / measure "index" of that closest time as well, and simply using
Min() wouldn't have helped on that, since it doesn't retain which of the values (e.g. the 2nd, or the 5th, and so on) is the minimum, it just provides the result value. For the record, this is the Min() variant:
Code: Select all
[Variables]
WOTIndex=5
Item=(?(?=.*\{).*\{"attack_type":.*,"front_id":".*","front_name":".*","competitor_id":.*,"time":(.*),"vehicle_level":.*,"province_id":".*","type":".*","province_name":".*"\},?)
WOTRegEx=(?siU)^.*\{"status":.*,"meta":\{"(?:quantity|count)":(.*)\},"data":\[#Item##Item##Item##Item##Item#\]\}.*$
[Rainmeter]
Update=1000
DynamicWindowSize=1
AccurateText=1
BackgroundMode=2
SolidColor=47,47,47,255
---Measures---
[MeasureUnixTimeStart]
Measure=Time
TimeStamp=03:00:00 01/01/1970
TimeStampFormat=%H:%M:%S %d/%m/%Y
FormatLocale=Local
UpdateDivider=-1
DynamicVariables=1
[CurrentTime]
Measure=Time
Format=%H:%M:%S %d/%m/%Y
FormatLocale=Local
[WOT]
Measure=WebParser
URL="file://#@#WOT#WOTIndex#.txt"
CodePage=1200
RegExp="#WOTRegEx#"
LogSubstringErrors=0
FinishAction=[!UpdateMeasureGroup WOTGroup][!UpdateMeterGroup WOTGroup][!Redraw]
OnConnectErrorAction=[!UpdateMeasureGroup WOTGroup][!UpdateMeterGroup WOTGroup][!Redraw]
OnRegExpErrorAction=[!UpdateMeasureGroup WOTGroup][!UpdateMeterGroup WOTGroup][!Redraw]
UpdateRate=-1
DynamicVariables=1
[Count]
Group=WOTGroup
Measure=WebParser
URL=[WOT]
StringIndex=1
UpdateDivider=-1
DynamicVariables=1
[Time1]
Group=WOTGroup
Measure=WebParser
URL=[WOT]
StringIndex=2
UpdateDivider=-1
DynamicVariables=1
[Time2]
Group=WOTGroup
Measure=WebParser
URL=[WOT]
StringIndex=3
UpdateDivider=-1
DynamicVariables=1
[Time3]
Group=WOTGroup
Measure=WebParser
URL=[WOT]
StringIndex=4
UpdateDivider=-1
DynamicVariables=1
[Time4]
Group=WOTGroup
Measure=WebParser
URL=[WOT]
StringIndex=5
UpdateDivider=-1
DynamicVariables=1
[Time5]
Group=WOTGroup
Measure=WebParser
URL=[WOT]
StringIndex=6
UpdateDivider=-1
DynamicVariables=1
[WindowsTime1]
Group=WOTGroup
Measure=Calc
Formula=([Time1:Timestamp]+[MeasureUnixTimeStart:Timestamp])
DynamicVariables=1
[MeasureTimeConvert1]
Group=WOTGroup
Measure=Time
TimeStamp=[WindowsTime1]
FormatLocale=Local
Format=%H:%M:%S %d/%m/%Y
RegExpSubstitute=1
Substitute="^03:00:00 01\/01\/1970$":"None"
DynamicVariables=1
[WindowsTime2]
Group=WOTGroup
Measure=Calc
Formula=([Time2:Timestamp]+[MeasureUnixTimeStart:Timestamp])
DynamicVariables=1
[MeasureTimeConvert2]
Group=WOTGroup
Measure=Time
TimeStamp=[WindowsTime2]
FormatLocale=Local
Format=%H:%M:%S %d/%m/%Y
RegExpSubstitute=1
Substitute="^03:00:00 01\/01\/1970$":"None"
DynamicVariables=1
[WindowsTime3]
Group=WOTGroup
Measure=Calc
Formula=([Time3:Timestamp]+[MeasureUnixTimeStart:Timestamp])
DynamicVariables=1
[MeasureTimeConvert3]
Group=WOTGroup
Measure=Time
TimeStamp=[WindowsTime3]
FormatLocale=Local
Format=%H:%M:%S %d/%m/%Y
RegExpSubstitute=1
Substitute="^03:00:00 01\/01\/1970$":"None"
DynamicVariables=1
[WindowsTime4]
Group=WOTGroup
Measure=Calc
Formula=([Time4:Timestamp]+[MeasureUnixTimeStart:Timestamp])
DynamicVariables=1
[MeasureTimeConvert4]
Group=WOTGroup
Measure=Time
TimeStamp=[WindowsTime4]
FormatLocale=Local
Format=%H:%M:%S %d/%m/%Y
RegExpSubstitute=1
Substitute="^03:00:00 01\/01\/1970$":"None"
DynamicVariables=1
[WindowsTime5]
Group=WOTGroup
Measure=Calc
Formula=([Time5:Timestamp]+[MeasureUnixTimeStart:Timestamp])
DynamicVariables=1
[MeasureTimeConvert5]
Group=WOTGroup
Measure=Time
TimeStamp=[WindowsTime5]
FormatLocale=Local
Format=%H:%M:%S %d/%m/%Y
RegExpSubstitute=1
Substitute="^03:00:00 01\/01\/1970$":"None"
DynamicVariables=1
[MinTimeDifference]
Group=WOTGroup
Measure=Calc
Formula=(Min(Min(Min(Min(([WindowsTime1:Timestamp]<[CurrentTime:Timestamp]?999999999:([WindowsTime1:Timestamp]-[CurrentTime:Timestamp])),([WindowsTime2:Timestamp]<[CurrentTime:Timestamp]?999999999:([WindowsTime2:Timestamp]-[CurrentTime:Timestamp]))),([WindowsTime3:Timestamp]<[CurrentTime:Timestamp]?999999999:([WindowsTime3:Timestamp]-[CurrentTime:Timestamp]))),([WindowsTime4:Timestamp]<[CurrentTime:Timestamp]?999999999:([WindowsTime4:Timestamp]-[CurrentTime:Timestamp]))),([WindowsTime5:Timestamp]<[CurrentTime:Timestamp]?999999999:([WindowsTime5:Timestamp]-[CurrentTime:Timestamp]))))
DynamicVariables=1
[MinTimeDifferenceConvert]
Group=WOTGroup
Measure=UpTime
SecondsValue=[MinTimeDifference]
Format="%4!i!d %3!i!h %2!i!m %1!i!s"
RegExpSubstitute=1
Substitute="^11574d 1h 46m 39s$":"None"
DynamicVariables=1
[MinTime]
Group=WOTGroup
Measure=Calc
Formula=([MinTimeDifference:Timestamp]=999999999?[MeasureUnixTimeStart:Timestamp]:([CurrentTime:Timestamp]+[MinTimeDifference:Timestamp]))
DynamicVariables=1
[MinTimeConvert]
Group=WOTGroup
Measure=Time
TimeStamp=[MinTime]
FormatLocale=Local
Format=%H:%M:%S %d/%m/%Y
RegExpSubstitute=1
Substitute="^03:00:00 01\/01\/1970$":"None"
DynamicVariables=1
---Meters---
[CountText]
Group=WOTGroup
Meter=String
FontFace=Consolas
FontColor=255,255,255,255
SolidColor=47,47,47,255
Padding=5,5,5,5
FontSize=16
AntiAlias=1
MeasureName=Count
Text="Count: %1"
UpdateDivider=-1
DynamicVariables=1
[TimeConvert1Text]
Group=WOTGroup
Meter=String
Y=0R
FontFace=Consolas
FontColor=255,255,255,255
SolidColor=47,47,47,255
Padding=5,5,5,5
FontSize=16
AntiAlias=1
MeasureName=MeasureTimeConvert1
Text="Time1: %1"
UpdateDivider=-1
DynamicVariables=1
[TimeConvert2Text]
Group=WOTGroup
Meter=String
Y=0R
FontFace=Consolas
FontColor=255,255,255,255
SolidColor=47,47,47,255
Padding=5,5,5,5
FontSize=16
AntiAlias=1
MeasureName=MeasureTimeConvert2
Text="Time2: %1"
UpdateDivider=-1
DynamicVariables=1
[TimeConvert3Text]
Group=WOTGroup
Meter=String
Y=0R
FontFace=Consolas
FontColor=255,255,255,255
SolidColor=47,47,47,255
Padding=5,5,5,5
FontSize=16
AntiAlias=1
MeasureName=MeasureTimeConvert3
Text="Time3: %1"
UpdateDivider=-1
DynamicVariables=1
[TimeConvert4Text]
Group=WOTGroup
Meter=String
Y=0R
FontFace=Consolas
FontColor=255,255,255,255
SolidColor=47,47,47,255
Padding=5,5,5,5
FontSize=16
AntiAlias=1
MeasureName=MeasureTimeConvert4
Text="Time4: %1"
UpdateDivider=-1
DynamicVariables=1
[TimeConvert5Text]
Group=WOTGroup
Meter=String
Y=0R
FontFace=Consolas
FontColor=255,255,255,255
SolidColor=47,47,47,255
Padding=5,5,5,5
FontSize=16
AntiAlias=1
MeasureName=MeasureTimeConvert5
Text="Time5: %1"
UpdateDivider=-1
DynamicVariables=1
[ClosestAfterCurrentTimeText]
Group=WOTGroup
Meter=String
Y=10R
FontFace=Consolas
FontColor=255,255,255,255
SolidColor=47,47,47,255
Padding=5,5,5,5
FontSize=16
AntiAlias=1
MeasureName=MinTimeConvert
MeasureName2=MinTimeDifferenceConvert
Text="Closest After Current Time#CRLF# Time: %1#CRLF# Diff: %2"
DynamicVariables=1
You do not have the required permissions to view the files attached to this post.