Page 2 of 8

Re: Display image based on sunrise / sunset measures

Posted: August 25th, 2018, 2:43 pm
by xenium
How could i calculate the time difference, between [MeasureSunset] and [MeasureSunrise] ?

Re: Display image based on sunrise / sunset measures

Posted: August 25th, 2018, 3:01 pm
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.

Re: Display image based on sunrise / sunset measures

Posted: August 25th, 2018, 4:31 pm
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 ? :???:

Re: Display image based on sunrise / sunset measures

Posted: August 25th, 2018, 4:36 pm
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].

Re: Display image based on sunrise / sunset measures

Posted: August 25th, 2018, 4:53 pm
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:

Re: Display image based on sunrise / sunset measures

Posted: August 25th, 2018, 5:10 pm
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?

Re: Display image based on sunrise / sunset measures

Posted: August 25th, 2018, 5:33 pm
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.

Re: Display image based on sunrise / sunset measures

Posted: August 25th, 2018, 5:36 pm
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?

Re: Display image based on sunrise / sunset measures

Posted: August 25th, 2018, 6:02 pm
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.

Re: Display image based on sunrise / sunset measures

Posted: August 25th, 2018, 6:05 pm
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?