It is currently May 18th, 2021, 11:09 pm

IfCondition=[MeasureUnixTime] > [MeasureRealTime]

Help with creating, editing & fixing problems with skins
MaestroSky
Posts: 16
Joined: April 20th, 2021, 4:15 pm

IfCondition=[MeasureUnixTime] > [MeasureRealTime]

Post by MaestroSky »

Tell me if it is possible to implement
Measure=Calc or something else,
the time obtained in unix code (but then it is translated into a simple time value) with real time?
I would like my skin to run in the interval between unix time and real time the rest of the time is silent.
User avatar
CyberTheWorm
Posts: 776
Joined: August 22nd, 2016, 11:32 pm
Location: Surrey, B.C., Canada

Re: IfCondition=[MeasureUnixTime] > [MeasureRealTime]

Post by CyberTheWorm »

maybe this would be what you need https://docs.rainmeter.net/snippets/convert-time/
The only source of knowledge is experience. Albert Einstein
Deviant Art Page
MaestroSky
Posts: 16
Joined: April 20th, 2021, 4:15 pm

Re: IfCondition=[MeasureUnixTime] > [MeasureRealTime]

Post by MaestroSky »

I'm not very good at this, but I tried to gather information and do it without success.
I did WinToUnix.lua file

Code: Select all

function ConvertTime(n, To)
	local Formats = {
		Unix    = -1
		Windows = 1
		}
	return Formats[To] and n + 11644473600 * Formats[To] or nil
end
Then he added this:

Code: Select all

[MeasureTimeReal]
Measure=Time
Format=%H:%M 

[MeasureScript]
Measure=Script
ScriptFile=WinToUnix.lua
Disabled=1

[MeterWelcome]
Meter=String
FontSize=20
FontWeight=400
FontColor=255,255,255,255
SolidColor=47,47,47,255
Padding=5,5,5,5
AntiAlias=1
Text=[&MeasureScript:ConvertTime('[&MeasureTimeReal]')]
DynamicVariables=1

After that I would like to compare the resulting value with what I get from WebParser
User avatar
jsmorley
Developer
Posts: 21694
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: IfCondition=[MeasureUnixTime] > [MeasureRealTime]

Post by jsmorley »

Let me get the lay of the land here a bit...

So what you get from WebParser is a Unix timestamp value like 1619777739 or some such?

And you want to compare that to the current time?

Unless I'm misunderstanding, I don't think Lua needs to play a role in this.
MaestroSky
Posts: 16
Joined: April 20th, 2021, 4:15 pm

Re: IfCondition=[MeasureUnixTime] > [MeasureRealTime]

Post by MaestroSky »

jsmorley wrote: April 30th, 2021, 10:16 am Let me get the lay of the land here a bit...

So what you get from WebParser is a Unix timestamp value like 1619777739 or some such?

And you want to compare that to the current time?

Unless I'm misunderstanding, I don't think Lua needs to play a role in this.
Yes, everything is correct, as you described.


At this stage, I didn't understand how to convert standard time to unix, so I had to do this:

Code: Select all

[InfoUnixTime]
Measure=WebParser
URL=https://converter.by/unixtime
UpdateRate=#UpdateTime#
RegExp="(?siU)<span class="btn btn-dark-green current-unix-time" id="current-unix-time">(.*)</span>"
UpdateDivider=-1
DynamicVariables=1

[MeasureInfoUnixTime]
Measure=WebParser
URL=[InfoUnixTime]
StringIndex=1
;RegExpSubstitute=1
DynamicVariables=1
UpdateDivider=-1
But I can't make a comparison of the resulting UNIX with the real one for running the meter.
Like something like that:

Code: Select all

[Meter]
Meter=String
IfCondition==(#UnixTime# > [MeasureInfoUnixTime])
IfTrueAction=[!RainmeterHideMeter MeterIconEmpty][!RainmeterShowMeter MeterIconFull][!RainmeterShowMeter MeterCount]
IfFalseAction=[!RainmeterHideMeter MeterIconFull][!RainmeterShowMeter MeterIconEmpty][!RainmeterHideMeter MeterCount]
DynamicVariables=1
Last edited by MaestroSky on April 30th, 2021, 10:34 am, edited 2 times in total.
User avatar
jsmorley
Developer
Posts: 21694
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: IfCondition=[MeasureUnixTime] > [MeasureRealTime]

Post by jsmorley »

Code: Select all

[Rainmeter]
Update=1000
DynamicWindowSize=1
AccurateText=1

[Variables]

[MeasureUnixTimeStamp]
; This simulates a WebParser measure
Measure=String
String=1619777739

[MeasureUnixTimeToWindows]
Measure=Time
Timestamp=([MeasureUnixTimeStamp]+11644473600)
Format=%A, %B %#d, %Y %#I:%M %p
DynamicVariables=1

[MeasureCurrentTime]
Measure=Time
Format=%A, %B %#d, %Y %#I:%M %p

[MeasureDifferenceInSeconds]
Measure=Calc
Formula=[MeasureUnixTimeToWindows:Timestamp] - [MeasureCurrentTime:TimeStamp]
DynamicVariables=1

[MeasureDifferenceFormatted]
Measure=UpTime
SecondsValue=[MeasureDifferenceInSeconds]
Format="%4!i!d %3!i!h %2!i!m %1!i!s"
DynamicVariables=1

[MeterDummy]
Meter=String

1.png
You do not have the required permissions to view the files attached to this post.
MaestroSky
Posts: 16
Joined: April 20th, 2021, 4:15 pm

Re: IfCondition=[MeasureUnixTime] > [MeasureRealTime]

Post by MaestroSky »

jsmorley wrote: April 30th, 2021, 10:33 am

Code: Select all

[Rainmeter]
Update=1000
DynamicWindowSize=1
AccurateText=1

[Variables]

[MeasureUnixTimeStamp]
; This simulates a WebParser measure
Measure=String
String=1619777739

[MeasureUnixTimeToWindows]
Measure=Time
Timestamp=([MeasureUnixTimeStamp]+11644473600)
Format=%A, %B %#d, %Y %#I:%M %p
DynamicVariables=1

[MeasureCurrentTime]
Measure=Time
Format=%A, %B %#d, %Y %#I:%M %p

[MeasureDifferenceInSeconds]
Measure=Calc
Formula=[MeasureUnixTimeToWindows:Timestamp] - [MeasureCurrentTime:TimeStamp]
DynamicVariables=1

[MeasureDifferenceFormatted]
Measure=UpTime
SecondsValue=[MeasureDifferenceInSeconds]
Format="%4!i!d %3!i!h %2!i!m %1!i!s"
DynamicVariables=1

[MeterDummy]
Meter=String


1.png
In this case, there is a real-time conversion of unix
And I need the opposite.
User avatar
jsmorley
Developer
Posts: 21694
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: IfCondition=[MeasureUnixTime] > [MeasureRealTime]

Post by jsmorley »

MaestroSky wrote: April 30th, 2021, 10:42 am In this case, there is a real-time conversion of unix
And I need the opposite.
I don't understand.
User avatar
jsmorley
Developer
Posts: 21694
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: IfCondition=[MeasureUnixTime] > [MeasureRealTime]

Post by jsmorley »

I can't see what possible difference it makes if you convert the Unix timestamp to Windows, or the Windows timestamp to Unix, the goal here is presumably to get both times into a common timestamp value, since you want to compare them. Either way is certainly possible, but I don't see the difference.
MaestroSky
Posts: 16
Joined: April 20th, 2021, 4:15 pm

Re: IfCondition=[MeasureUnixTime] > [MeasureRealTime]

Post by MaestroSky »

jsmorley wrote: April 30th, 2021, 10:43 am I don't understand.
You have specified how to translate from unix to the present time. And I need the opposite, from now on in unix.
Last edited by MaestroSky on April 30th, 2021, 11:01 am, edited 1 time in total.