It is currently March 28th, 2024, 5:54 pm

Display image based on sunrise / sunset measures

Get help with creating, editing & fixing problems with skins
User avatar
xenium
Posts: 841
Joined: January 4th, 2018, 9:52 pm

Re: Display image based on sunrise / sunset measures

Post by xenium »

How could i calculate the time difference, between [MeasureSunset] and [MeasureSunrise] ?
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Display image based on sunrise / sunset measures

Post by balala »

xenium wrote:How could i calculate the time difference, between [MeasureSunset] and [MeasureSunrise] ?
First let's clarify something: you need the time difference between [MeasureSunset] and [MeasureSunrise], or vice-versa, between [MeasureSunrise] and [MeasureSunset]? Because last one is the length of the day, while the first (what you asked for) is the length of the night.
Anyway, if you need the difference between [MeasureSunrise] and [MeasureSunset], it's a bit easier: you simply have to extract the numeric value of [MeasureSunrise], from the numeric value of [MeasureSunset] (keep in mind that [MeasureSunset] and [MeasureSunrise] are not numbers, so you can't extract them, but you can extract the [MeasureSunsetMoment] and [MeasureSunriseMoment], which are numbers):

Code: Select all

[MeasureDayLength]
Measure=Calc
Formula=( MeasureSunsetMoment - MeasureSunriseMoment )
On the other hand, if you need to get the length of the night, you have to calculate the length of day, then extract the got value from 1440 (number of minutes into a day):

Code: Select all

[MeasureNightLength]
Measure=Calc
Formula=( 1440 - MeasureSunsetMoment + MeasureSunriseMoment )
In both cases you'll get the result into minutes.

IMPORTANT: Don't forget to convert this to seconds, hours or whatever you need.
User avatar
xenium
Posts: 841
Joined: January 4th, 2018, 9:52 pm

Re: Display image based on sunrise / sunset measures

Post by xenium »

balala wrote:First let's clarify something: you need the time difference between [MeasureSunset] and [MeasureSunrise], or vice-versa, between [MeasureSunrise] and [MeasureSunset]? Because last one is the length of the day, while the first (what you asked for) is the length of the night.
Anyway, if you need the difference between [MeasureSunrise] and [MeasureSunset], it's a bit easier: you simply have to extract the numeric value of [MeasureSunrise], from the numeric value of [MeasureSunset] (keep in mind that [MeasureSunset] and [MeasureSunrise] are not numbers, so you can't extract them, but you can extract the [MeasureSunsetMoment] and [MeasureSunriseMoment], which are numbers):

Code: Select all

[MeasureDayLength]
Measure=Calc
Formula=( MeasureSunsetMoment - MeasureSunriseMoment )
On the other hand, if you need to get the length of the night, you have to calculate the length of day, then extract the got value from 1440 (number of minutes into a day):

Code: Select all

[MeasureNightLength]
Measure=Calc
Formula=( 1440 - MeasureSunsetMoment + MeasureSunriseMoment )
In both cases you'll get the result into minutes.

IMPORTANT: Don't forget to convert this to seconds, hours or whatever you need.
... and how do I convert minutes into hours and minutes ? :???:
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Display image based on sunrise / sunset measures

Post by balala »

xenium wrote:... and how do I convert minutes into hours and minutes ? :???:
For example with the following two Calc measures:

Code: Select all

[MeasureDayLengthHour]
Measure=Calc
Formula=( Floor ( MeasureDayLength / 60 ))

[MeasureDayLengthMinute]
Measure=Calc
Formula=( MeasureDayLength % 60 )
If needed same way you can convert the [MeasureNightLength].
User avatar
xenium
Posts: 841
Joined: January 4th, 2018, 9:52 pm

Re: Display image based on sunrise / sunset measures

Post by xenium »

balala wrote:For example with the following two Calc measures:

Code: Select all

[MeasureDayLengthHour]
Measure=Calc
Formula=( Floor ( MeasureDayLength / 60 ))

[MeasureDayLengthMinute]
Measure=Calc
Formula=( MeasureDayLength % 60 )
If needed same way you can convert the [MeasureNightLength].
Many thanks ! :bow:
... and I apologize for stressing you with so many questions. :rosegift:
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Display image based on sunrise / sunset measures

Post by balala »

xenium wrote:Many thanks ! :bow:
... and I apologize for stressing you with so many questions. :rosegift:
You're welcome.
Don't worry, no stress at all. If you would stress me in worst case I wouldn't reply.
But finally have you got the skin working as intended?
User avatar
xenium
Posts: 841
Joined: January 4th, 2018, 9:52 pm

Re: Display image based on sunrise / sunset measures

Post by xenium »

balala wrote:You're welcome.
Don't worry, no stress at all. If you would stress me in worst case I wouldn't reply.
But finally have you got the skin working as intended?
Yes, it now works exactly what I wanted.
 I still have to do, and the AM / PM version.
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Display image based on sunrise / sunset measures

Post by balala »

xenium wrote:I still have to do, and the AM / PM version.
You mean you'd like to convert the Sunrise / Sunset to 12 hours format?
User avatar
xenium
Posts: 841
Joined: January 4th, 2018, 9:52 pm

Re: Display image based on sunrise / sunset measures

Post by xenium »

balala wrote:You mean you'd like to convert the Sunrise / Sunset to 12 hours format?
Yes
If change the link in the code in the first post with https://www.foreca.com/Bulgaria/Sofia?units=us&tf=12h, MeasureSunrise and MeasureSunset will display the hours in the 12 hours format.
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Display image based on sunrise / sunset measures

Post by balala »

xenium wrote:If change the link in the code in the first post with https://www.foreca.com/Bulgaria/Sofia?units=us&tf=12h, MeasureSunrise and MeasureSunset will display the hours in the 12 hours format.
Yes, but in this case all measures have to be rewritten. Do you know how to do this?
Post Reply