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

Using WebParser to retrieve a DateTime as string and converting it.

Get help with creating, editing & fixing problems with skins
User avatar
Mustachio
Posts: 3
Joined: August 7th, 2018, 2:14 pm

Using WebParser to retrieve a DateTime as string and converting it.

Post by Mustachio »

Hello,

I'm trying to make a skin which has a simple countdown to night-time/daytime in a game.
Right now I have a plethora of issues which I can't wrap my head around. List time!: :17flag
  • The input format: Can I natively convert a string with a format %Y-%m-%dT%H:%M:%S.000Z to a Time, and if not, how should it be formatted? I believe the milliseconds are in the way, but how am i supposed to ignore the 'Z' with RegExp then?
  • The time on the API is UTC, how do I properly convert it to the system's timezone? I haven't looked into this yet since without a time in the first place it isn't really worth doing, so not priority at all
The .ini file
I'm aware that there is a timeLeft in the API, but that one doesn't update the seconds properly.

Thanks in advance :)
User avatar
FreeRaider
Posts: 826
Joined: November 20th, 2012, 11:58 pm

Re: Using WebParser to retrieve a DateTime as string and converting it.

Post by FreeRaider »

I do not understand what you mean "convert a string with a format %Y-%m-%dT%H:%M:%S.000Z to a Time"

Do you want %Y-%m-%dT%H:%M:%S.000Z to %Y-%m-%d H:%M:%S or what?
User avatar
Mustachio
Posts: 3
Joined: August 7th, 2018, 2:14 pm

Re: Using WebParser to retrieve a DateTime as string and converting it.

Post by Mustachio »

I want to retrieve the %Y-%m-%dT%H:%M:%S.000Z string in a format which will successfully convert to a timestamp, so that I can calculate a time difference with the current timestamp, since the %Y-%m-%dT%H:%M:%S.000Z format doesn't want to return any value.
User avatar
eclectic-tech
Rainmeter Sage
Posts: 5382
Joined: April 12th, 2012, 9:40 pm
Location: Cedar Point, Ohio, USA

Re: Using WebParser to retrieve a DateTime as string and converting it.

Post by eclectic-tech »

Code: Select all

[Rainmeter]
Author=Mustachio
Update=1000
DynamicWindowSize=1

[MeasureParent]
Measure=WebParser
UpdateRate=1
URL=https://api.warframestat.us/pc/cetusCycle
RegExp=(?siU)expiry":"(.*)".*shortString":".*to (.*)"
;\d{4}-\d{2}-\d{2}T(.*).{5}

[MeasureExpiry]
Measure=WebParser
URL=[MeasureParent]
StringIndex=1

[MeasureState]
Measure=WebParser
URL=[MeasureParent]
StringIndex=2

[CurrentDateTime]
Measure=Time
;Format=%Y-%m-%dT%H:%M:%S

[MeasureExpiryDate]
Measure=Time
TimeStamp=[MeasureExpiry]
TimeStampFormat=%Y-%m-%dT%H:%M:%S
DynamicVariables=1

[MeasureDaysDifference]
Measure=Calc
Formula=(ABS([CurrentDateTime:TimeStamp] - [MeasureExpiryDate:]))
DynamicVariables=1

[ConvertedTimeDelta]
Measure=Time
TimeStamp=[MeasureDaysDifference:]
DynamicVariables=1

[MeterTime]
Meter=String
MeasureName=ConvertedTimeDelta
X=400
Y=0r
W=500
H=75
FontFace=ITC Avant Garde Pro XLt
FontSize=24
FontColor=255,255,255,255
SolidColor=0,0,0,1
Padding=5,5,5,5
StringAlign=Right
ClipString=1
AntiAlias=1
TimeStampFormat Note: These values cannot evaluate any time zone information in the string and cannot be modified with the TimeZone option. What is internally arrived at by the measure is a resolution of the date and/or time string to a Windows timestamp, which is a number of seconds since January 1, 1601, and independent of any time zone.
User avatar
FreeRaider
Posts: 826
Joined: November 20th, 2012, 11:58 pm

Re: Using WebParser to retrieve a DateTime as string and converting it.

Post by FreeRaider »

Mustachio wrote:I want to retrieve the %Y-%m-%dT%H:%M:%S.000Z string in a format which will successfully convert to a timestamp, so that I can calculate a time difference with the current timestamp, since the %Y-%m-%dT%H:%M:%S.000Z format doesn't want to return any value.

Code: Select all

[MeasureParent]
...
FinishAction=[!EnableMeasureGroup Times][!UpdateMeasureGroup Times]

[MeasureExpiryDate]
Measure=Time
TimeStampFormat=%Y-%m-%dT%H:%M:%S.000Z
TimeStamp=[MeasureExpiry]
DynamicVariables=1
Group=Times
Disabled=1
It returns 13178195520 (at this moment)
User avatar
Mustachio
Posts: 3
Joined: August 7th, 2018, 2:14 pm

Re: Using WebParser to retrieve a DateTime as string and converting it.

Post by Mustachio »

Thanks for the replies!

Functional now, I suppose that's what happens when you fail to adhere to basic syntax :oops:
User avatar
FreeRaider
Posts: 826
Joined: November 20th, 2012, 11:58 pm

Re: Using WebParser to retrieve a DateTime as string and converting it.

Post by FreeRaider »

Glad if I helped you.
User avatar
eclectic-tech
Rainmeter Sage
Posts: 5382
Joined: April 12th, 2012, 9:40 pm
Location: Cedar Point, Ohio, USA

Re: Using WebParser to retrieve a DateTime as string and converting it.

Post by eclectic-tech »

Me Too! :17good