It is currently March 29th, 2024, 1:00 pm

Simple Idea = Confusing : Comparing Times (I know this has been beaten to death)

Get help with creating, editing & fixing problems with skins
User avatar
Mor3bane
Posts: 943
Joined: May 7th, 2016, 7:32 am

Simple Idea = Confusing : Comparing Times (I know this has been beaten to death)

Post by Mor3bane »

So I have this adaptation of a sun position meter which is derived from several Webparsers. Lots of code here, I'll post it all since there may be factors that involve whatever Meters/Meters...

I simply wish for a little sun png to change to a moon png when the sunset time is reached, then go back to a sun after midnight.

Here's the stuff - sorry about the many variables...

Code: Select all

[Rainmeter]
Update=5000
Author=2ndidentity/Morbane
AccurateText=1
Group=Big

[Metadata]
Description=Displays the position of the sun.

[Variables]
@Include=#@#RoundVariables.inc
FontFace="Astronaut"
FontColor=#GlobalFontColor#
Color=#GlobalFontColor#
ColorZ=#ColorOffset#
ProgressCir=85,215,202
LocationCode=#GlobalLocation#
Units=c
Width=182
Height=90
Xorigin=25
Yorigin=70
WebParserSunRiseSet=<sunr>(.*):(.*) (.*)</sunr>.*<suns>(.*):(.*) (.*)</suns>
Goth=#Gothic#

[MeasureParent]
Measure=WebParser
URL=https://wxdata.weather.com/wxdata/weather/local/#LocationCode#?cc=*&unit=#Units#&dayf=1
RegExp="(?siU)#WebParserSunRiseSet#"
Debug=2

[Background]
Meter=Image
ImageName=#@#Background.png
X=39
Y=43

;===== MeasureSunrise/set ======;
[MeasureAstronomySunriseHour]
Measure=WebParser
URL=[MeasureParent]
StringIndex=1

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

[MeasureAstronomySunriseAMPM]
Measure=WebParser
URL=[MeasureParent]
StringIndex=3
Substitute="AM":"0","PM":"1"

[MeasureAstronomySunsetHour]
Measure=WebParser
URL=[MeasureParent]
StringIndex=4

[MeasureAstronomySunsetMin]
Measure=WebParser
URL=[MeasureParent]
StringIndex=5

[MeasureAstronomySunsetAMPM]
Measure=WebParser
URL=[MeasureParent]
StringIndex=6
Substitute="AM":"0","PM":"1"

;===== MeasurePosition =========;
[MeasureAstronomySunriseHourAdjust]
Measure=Calc
Formula=[MeasureAstronomySunriseAMPM]*12+MeasureAstronomySunriseHour
Percentual=1
DynamicVariables=1

[MeasureAstronomySunsetHourAdjust]
Measure=Calc
Formula=[MeasureAstronomySunsetAMPM]*12+MeasureAstronomySunsetHour
Percentual=1
DynamicVariables=1

[MeasureDifferenceinMin]
Measure=Calc
Formula=(MeasureAstronomySunsetHourAdjust*60+MeasureAstronomySunsetMin)-(MeasureAstronomySunriseHourAdjust*60+MeasureAstronomySunriseMin)

[MeasureCurrentHour]
Measure=Time
Format=%H

[MeasureCurrentMin]
Measure=Time
Format=%M

[MeasurePosition1]
Measure=Calc
Formula=((MeasureCurrentHour*60+MeasureCurrentMin)-(MeasureAstronomySunriseHourAdjust*60+MeasureAstronomySunriseMin))/MeasureDifferenceinMin

[MeasurePosition2]
Measure=Calc
Formula=MeasurePosition1 < 0 ? 0 : (MeasurePosition1 < 1 ? MeasurePosition1 : 1)

[MeasureX]
Measure=Calc
Formula=#Xorigin#+0.5*#Width#*(1-cos(pi*MeasurePosition2))

[MeasureY]
Measure=Calc
Formula=#Yorigin#+#Height#*(1-sin(pi*MeasurePosition2))

;===== Meters ==================;
[MeterSunTrail]
Meter=Image
ImageName=#@#SunTrail.png
ImageTint=#FontColor#
W=252
H=152
X=43
Y=45

[MeterSunIcon]
Meter=Image
ImageName=#@#Sunb.png
ImageTint=#Goth#
W=35
H=35
X=([MeasureX] + 35)
Y=([MeasureY] - 5 )
DynamicVariables=1

[MeterAstronomySunrise]
Meter=String
FontColor=#FontColor#
FontFace=#FontFace#
FontSize=13
AntiAlias=1
ClipString=1
StringAlign=Left
MeasureName=MeasureAstronomySunriseHourAdjust
MeasureName2=MeasureAstronomySunriseMin
W=75
H=20
X=67
Y=175
Text=%1:%2

[MeterAstronomySunset]
Meter=String
FontColor=#FontColor#
FontFace=#FontFace#
FontSize=13
AntiAlias=1
ClipString=1
StringAlign=Right
MeasureName=MeasureAstronomySunsetHourAdjust
MeasureName2=MeasureAstronomySunsetMin
W=75
H=20
X=200r
Y=r
Text=%1:%2

[MeterText]
Meter=String
FontColor=#Goth#
FontFace=#FontFace#
FontSize=17
AntiAlias=1
StringAlign=Center
Text="SUN POSITION"
X=169
Y=178
DynamicVariables=1

[MeterImageBottom]
Meter=Image
ImageAlpha=200
ImageName=#@#ChapterC.png
ImageTint=#Goth#
ImageFlip=Vertical
X=95
Y=209
W=150
H=38
Group=Digital
AntiAlias=1

;===== Measure Sundial ======;
[MeterSundial]
Meter=RoundLine
X=170
Y=135
LineLength=20
LineStart=18
LineColor=#FontColor#
Solid=1
Antialias=1

[MeterVertNums]
Meter=String
FontFace=#FontFace#
FontColor=#ColorZ#
FontSize=12
AntiAlias=1
StringAlign=Center
Text="24#CRLF##CRLF##CRLF#12"
X=167
Y=100
DynamicVariables=1

[MeterHorizNums]
Meter=String
FontFace=#FontFace#
FontColor=#ColorZ#
FontSize=12
AntiAlias=1
StringAlign=Center
Text="18        6"
X=167
Y=125
DynamicVariables=1

[MeasureTimeUp]
Measure=Calc
Formula=((MeasureAstronomySunsetHourAdjust * 60 + MeasureAstronomySunsetMin)-(MeasureAstronomySunriseHour * 60 + MeasureAstronomySunriseMin)) / 1440

[MeterSunUp]
Meter=Roundline
MeasureName=MeasureTimeUp
X=170
Y=135
LineLength=20
LineStart=16
StartAngle=(Rad(270+([MeasureAstronomySunriseHour] * 15) + ([MeasureAstronomySunriseMin] * 0.25)))
RotationAngle=(Rad(360))
LineColor=#ColorZ#
Solid=1
AntiAlias=1
DynamicVariables=1
I looked at several examples but they all just confused me as they were not relative to this idea.

Thanks for any help.
My DevArt Gallery

There are many ways to be different - there is only one way to be yourself - be amazing at it

The law of averages says what it means; even if you get everything right, you will get something wrong. Therefore; self managing error trapping initiates another set of averages - amongst the errors, some of them will not be errors, instead those instances will appear to be "luck". One cannot complain of the 'appearance' of 'infinite regress of causation', even if it does not have a predictable pattern, only that it requires luck to achieve.
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Simple Idea = Confusing : Comparing Times (I know this has been beaten to death)

Post by jsmorley »

Would you want the moon between the sunset and sunrise hours?
User avatar
Mor3bane
Posts: 943
Joined: May 7th, 2016, 7:32 am

Re: Simple Idea = Confusing : Comparing Times (I know this has been beaten to death)

Post by Mor3bane »

jsmorley wrote:Would you want the moon between the sunset and sunrise hours?
Oh, yes it would remain until midnight, then change back to the sun. :)

The moon.png would not need to move or anything like that.
My DevArt Gallery

There are many ways to be different - there is only one way to be yourself - be amazing at it

The law of averages says what it means; even if you get everything right, you will get something wrong. Therefore; self managing error trapping initiates another set of averages - amongst the errors, some of them will not be errors, instead those instances will appear to be "luck". One cannot complain of the 'appearance' of 'infinite regress of causation', even if it does not have a predictable pattern, only that it requires luck to achieve.
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Simple Idea = Confusing : Comparing Times (I know this has been beaten to death)

Post by jsmorley »

What I'm saying is that it is still "dark" from sunset to sunrise, not sunset to midnight...

Anyway, I don't have nearly enough of your skin to be able to do much with that, but here is some code that deals with sunrise / sunset. The key is that most places that provide the data do so in AM / PM terms, and you must convert that to 24-hour time to do any comparisons.

Code: Select all

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

[Variables]
TimeColor=232,232,232
DayColor=242,232,177
NightColor=150,147,128

LocationCode=USVA0944

[MeasureTime12]
Measure=Time
Format=%#I:%M

[MeasureSiteSun]
Measure=WebParser
URL=https://wxdata.weather.com/wxdata/weather/local/#LocationCode#
RegExp=(?siU).*<sunr>(.*)</sunr>.*<suns>(.*)</suns>
FinishAction=[!EnableMeasureGroup Sun]

[MeasureSiteRise]
Measure=WebParser
URL=[MeasureSiteSun]
StringIndex=1
RegExpSubstitute=1
Substitute=":":"."," AM":"+0"," PM":"+12","^(.+)$":"(\1)","^$":"6.00"

[MeasureSiteSet]
Measure=WebParser
URL=[MeasureSiteSun]
StringIndex=2
RegExpSubstitute=1
Substitute=":":"."," AM":"+0"," PM":"+12","^(.+)$":"(\1)","^$":"18.00"

[MeasureTime24]
Measure=Time
Group=Sun
Format=%#H.%#M
Disabled=1

[MeasureSun]
Measure=Calc
Group=Sun
Formula=(MeasureTime24 >= 0) && (MeasureTime24 < 1) ? 1 : ((MeasureTime24 >= 12) && (MeasureTime24 < 13) ? 2 : (MeasureTime24 < 12 ? 3 : (MeasureTime24 < 16 ? 4 : 5)))
Substitute="1":"Midnight Hour","2":"Noon Hour","3":"Morning","4":"Afternoon","5":"Evening"
IfCondition=(MeasureTime24 > [MeasureSiteRise]) && (MeasureTime24 < [MeasureSiteSet])
IfTrueAction=[!SetOption MeterSun FontColor "#DayColor#"][!SetOption MeterSun Text "[MeasureSun]"]
IfFalseAction=[!SetOption MeterSun FontColor "#NightColor#"][!SetOption MeterSun Text "[MeasureSun]"]
DynamicVariables=1
IfConditionMode=1
Disabled=1

[MeterTime]
Meter=String
MeasureName=MeasureTime12
FontSize=44
FontColor=#TimeColor#
SolidColor=0,0,0,1
AntiAlias=1

[MeterSun]
Meter=String
X=([MeterTime:W] - 5)
Y=-7R
StringAlign=Right
FontSize=13
AntiAlias=1
DynamicVariables=1
1.jpg
You do not have the required permissions to view the files attached to this post.
User avatar
SilverAzide
Rainmeter Sage
Posts: 2588
Joined: March 23rd, 2015, 5:26 pm

Re: Simple Idea = Confusing : Comparing Times (I know this has been beaten to death)

Post by SilverAzide »

Sorry for interjecting on this thread, but as a public service announcement, I'll just mention that the only correct sunrise/sunset times in the Weather Channel feed are the values between the <loc></loc> tags. The sunrise/sunset times in the forecast section of the XML are all wrong -- they are just duplicates of the "today" value.
Gadgets Wiki GitHub More Gadgets...