I think this is simplest with a small Lua script:
Here is an example...
Test.ini
Code: Select all
[Rainmeter]
Update=1000
DynamicWindowSize=1
[MeasureWeather]
Measure=Plugin
Plugin=WebParser
URL=http://xml.weather.com/weather/local/UKXX0085?cc=*&unit=m&dayf=1
RegExp="(?siU)<lsup>.* (.*) Local Time</lsup>"
FinishAction=!EnableMeasure MeasureScript
[MeasureTime]
Measure=Plugin
Plugin=WebParser
URL=[MeasureWeather]
StringIndex=1
[MeasureScript]
Measure=Script
ScriptFile=Test.lua
Disabled=1
[MeterTime]
Meter=String
MeasureName=MeasureScript
FontSize=13
FontColor=255,255,255,255
AntiAlias=1
Test.lua
Code: Select all
function Initialize()
msMeasureTime = SKIN:GetMeasure("MeasureTime")
end
function Update()
updateTime = msMeasureTime:GetStringValue()
Hour, Minute, Meridiem = string.match(updateTime, '^(.-):(.-) (.-)$')
Hour24 = ParseTwelveHourTime(tonumber(Hour), Meridiem)
if tonumber(Hour24) < 10 then
Hour24 = '0'..Hour24
end
SELF:Disable()
return (Hour24..':'..Minute)
end
function ParseTwelveHourTime(Hour, Meridiem)
if (Meridiem == 'AM') and (Hour == 12) then
Hour = 0
elseif (Meridiem == 'PM') and (Hour < 12) then
Hour = Hour + 12
end
return Hour
end
What this is doing is getting the time information you want from weather.com, with the format "9:25 AM" or "2:15 PM" or whatever it is, using WebParser as normal.
Then when WebParser is done, it is enabling a Lua script measure that does the following:
* Gets the value of that measure returning the time from the skin.
* Uses a string.match function to break the time into Hour, Minute and Meridiem (AMPM)
* Uses a function to check the Meridiem and change the Hour into 24-hour format as needed.
* Adds a leading "0" if needed.
* Disables itself so it is not using resources until needed again.
* Returns the time formatted as "09:25" or "14:15" (using the examples above)
The skin then uses the value of the script measure when displaying the time.