Re: Display image based on sunrise / sunset measures
Posted: August 25th, 2018, 2:43 pm
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.xenium wrote:How could i calculate the time difference, between [MeasureSunset] and [MeasureSunrise] ?
Code: Select all
[MeasureDayLength]
Measure=Calc
Formula=( MeasureSunsetMoment - MeasureSunriseMoment )
Code: Select all
[MeasureNightLength]
Measure=Calc
Formula=( 1440 - MeasureSunsetMoment + MeasureSunriseMoment )
... and how do I convert minutes into hours and minutes ?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):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
[MeasureDayLength] Measure=Calc Formula=( MeasureSunsetMoment - MeasureSunriseMoment )
In both cases you'll get the result into minutes.Code: Select all
[MeasureNightLength] Measure=Calc Formula=( 1440 - MeasureSunsetMoment + MeasureSunriseMoment )
IMPORTANT: Don't forget to convert this to seconds, hours or whatever you need.
For example with the following two Calc measures:xenium wrote:... and how do I convert minutes into hours and minutes ?
Code: Select all
[MeasureDayLengthHour]
Measure=Calc
Formula=( Floor ( MeasureDayLength / 60 ))
[MeasureDayLengthMinute]
Measure=Calc
Formula=( MeasureDayLength % 60 )
Many thanks !balala wrote:For example with the following two Calc measures:If needed same way you can convert the [MeasureNightLength].Code: Select all
[MeasureDayLengthHour] Measure=Calc Formula=( Floor ( MeasureDayLength / 60 )) [MeasureDayLengthMinute] Measure=Calc Formula=( MeasureDayLength % 60 )
You're welcome.xenium wrote:Many thanks !
... and I apologize for stressing you with so many questions.
Yes, it now works exactly what I wanted.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?
You mean you'd like to convert the Sunrise / Sunset to 12 hours format?xenium wrote:I still have to do, and the AM / PM version.
Yesbalala wrote:You mean you'd like to convert the Sunrise / Sunset to 12 hours format?
Yes, but in this case all measures have to be rewritten. Do you know how to do this?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.