It is currently May 17th, 2024, 2:04 am

Converting TimeZone from WebParsed String

Get help with creating, editing & fixing problems with skins
Samalama
Posts: 12
Joined: November 3rd, 2012, 11:42 pm

Converting TimeZone from WebParsed String

Post by Samalama »

I'm creating a skin which uses WebParser to return the time in UTC and I would like to convert it to Pacific(-8). At this point I can convert the hour accurately, but I haven't been able to figure out how to switch between AM and PM when necessary. Any help would be appreciated.

Here's an example skin which uses the Rainmeter RSS Feed:

Code: Select all

[Rainmeter]
Update=500


[styleTime]
StringAlign=LEFT
StringStyle=BOLD
FontColor=255,255,255,255
FontSize=13
ClipString=0


[RSS]
Measure=Plugin
Plugin=WebParser
UpdateRate=86400
URL=http://rainmeter.net/forum/feed.php
RegExp="(?siU)<p>Statistics: Posted by <a href="">.*</a>.*2012 (.*):(.*) (.*)</p>"

[Hour]
Measure=Plugin
Plugin=WebParser
URL=[RSS]
StringIndex=1

[Min]
Measure=Plugin
Plugin=WebParser
URL=[RSS]
StringIndex=2

[AMpm]
Measure=Plugin
Plugin=WebParser
URL=[RSS]
StringIndex=3

[calc-Hour]
Measure=Calc
Formula=Hour - 8 + 12


[meter-Background]
Meter=Image
SolidColor=128,128,128
W=100
H=100


[meter-Hour]
Meter=STRING
MeterStyle=styleTime
MeasureName=calc-Hour
UpdateRate=86400
X=0
Y=10
W=150
H=100

[meter-Min]
Meter=STRING
MeterStyle=styleTime
MeasureName=Min
UpdateRate=86400
X=20
Y=10
W=150
H=100

[meter-AMpm]
Meter=String
MeterStyle=StyleTime
MeasureName=AMpm
X=45
Y=10
W=150
H=100
User avatar
Mordasius
Posts: 1173
Joined: January 22nd, 2011, 4:23 pm
Location: GMT +8

Re: Converting TimeZone from WebParsed String

Post by Mordasius »

I would be tempted to use the time between the <updated> </updated> labels and some Calc measures like those below:

Code: Select all

[Rainmeter]
Update=1000

[styleTime]
StringAlign=LEFT
StringStyle=BOLD
FontColor=255,255,255,255
FontSize=13
ClipString=0

[RSS]
Measure=Plugin
Plugin=WebParser
UpdateRate=86400
URL=http://rainmeter.net/forum/feed.php
; RegExp="(?siU)<p>Statistics: Posted by <a href="">.*</a>.*2012 (.*):(.*) (.*)</p>"
RegExp=(?siU)<updated>.*T(.*):(.*):.*</updated>

[Hour]
Measure=Plugin
Plugin=WebParser
URL=[RSS]
StringIndex=1

[Min]
Measure=Plugin
Plugin=WebParser
URL=[RSS]
StringIndex=2

[AMpm]
Measure=Calc
Formula=Hour-8>=0?(Hour-8): (16+Hour)
IfBelowValue=13
IfBelowAction=[!SetVariable AMpm-label "AM"]
IfAboveValue=12
IfAboveAction=[!SetVariable AMpm-label "PM"]

[calc-Hour]
Measure=Calc
Formula=Hour-8>=0?(Hour-8)%12: (16+Hour)%12

[meter-Background]
Meter=Image
SolidColor=128,128,128
W=100
H=100

[meter-Hour]
Meter=STRING
MeterStyle=styleTime
MeasureName=calc-Hour
X=0
Y=10
W=150
H=100

[meter-Min]
Meter=STRING
MeterStyle=styleTime
MeasureName=Min
X=20
Y=10
W=150
H=100

[meter-AMpm]
Meter=String
MeterStyle=StyleTime
; MeasureName=AMpm
X=45
Y=10
W=150
H=100
Text=#AMpm-label#
DynamicVariables=1
Note: There is no reason to have Update=500 on a skin like this and UpdateRate= only works with the the WebParser and Ping plugins. For meters you need to use UpdateDivider=.