I have been a Rainmeter user for nearly fifteen years, but must admit that the last weather.com update left me completely nonplussed. I would therefore like, first of all, to thank JS Morley & Co for all their (successful) efforts to make the new JSON weather version accessible to all. I freely admit that, without JS Morley, I would have been completely lost
Considering the above, I would like to give something back to the community and I remember that, some months ago, there was a question about time zones.
I like to see the interval between the last update and the current local time (pure laziness, of course!). This is, of course, simple within the same time-zone; but becomes more difficult when different time-zones are involved (every so often I like to check the weather in another part of the world).
The alphabetic time-zone abbreviations provided by weather.com (e.g., “EDT”) are absolutely useless, as they can mean anything and everything. I therefore extract the numeric time-zone (e.g., +0200) from each weather.com forecast page that I consult, and use this to calculate the time elapsed between the last update and my (local) system time.
My solution may be somewhat clunky (regular expressions are not my cup of tea), but it works; and I think that showing a location's time-zone is important. By the way, I would be happy to give any explanations needed; in the meantime, please feel free to use/adapt/improve as you wish.
One caveat: I have no idea how the measures/meters below would work with American formatting (e.g., "am").
Code: Select all
;WeatherComJSONMeasures
[@LocationTimeZone]
Measure=WebParser
URL=[@CurrentConditionsParent]
StringIndex=17
RegExpSubstitute=1
Substitute="+0000":"±0000","^.*(......)$":"\1",'"':""
; Measures
[@LocationTimeAdjusted]
; Location time adjusted for calculations
Measure=Time
TimeStamp=[@CurrentObservationTimeStamp]
TimeStampFormat=%Y-%m-%dT%H:%M
DynamicVariables=1
[@LocationZoneCalc]
; Location time-zone formatted for calculations
Measure=Calc
Formula=([@LocationTimeZone] * 0.01)
DynamicVariables=1
Substitute=".15":".25",".3":".5",".45":".75","±0000":"0"
[@LocalTimeAdjusted]
; Local (system) time adjusted for calculations using location time-zone
Measure=Time
TimeZone=[@LocationZoneCalc]
Format=%Y-%m-%dT%H:%M:%S
DynamicVariables=1
[@TimeDifference]
; Difference between location time and local (system) time, calculated using location time-zone for both
Measure=Calc
Formula=([@LocalTimeAdjusted:TimeStamp]-[@LocationTimeAdjusted:TimeStamp])
; Change MeterTimeElapsed text if time difference > 24h
IfAboveValue=86399
IfAboveAction=[!SetOption MeterTimeElapsed Text "> 24h"]
; Otherwise keep things as they are
IfBelowValue=86400
IfBelowAction=[!SetOption MeterTimeElapsed Text "%1"]
DynamicVariables=1
[@TimeElapsed]
; @TimeDifference formatted for display
Measure=Time
TimeStamp=[@TimeDifference]
Format=%#Hh %#Mm
DynamicVariables=1
RegExpSubstitute=1
Substitute="^0h 0m":"< 1m","^0h ":""
; Meters
[SeparatorUpdate]
Meter=IMAGE
MeterStyle=sSeparator
[MeterUpdateString]
Meter=STRING
Text="Last update"
[MeterUpdate]
MeasureName=@CurrentObservationTime
Meter=String
Text=%1
[SeparatorTimeElapsed]
Meter=IMAGE
MeterStyle=sSeparator
[MeterTimeElapsedString]
Meter=STRING
Text="Time elapsed"
[MeterTimeElapsed]
MeasureName=@TimeElapsed
Meter=String
[SeparatorTimeZone]
Meter=IMAGE
MeterStyle=sSeparator
[MeterTimeZoneString]
Meter=STRING
Text="Time zone"
[MeterTimeZone]
MeasureName=@LocationTimeZone
Meter=String
Thanks again for all your help.