Please enable JavaScript to view this site.

 

int = EarliestVisibleMoonRiseSet(nDate nSunSourceIndex)

 

This macro function calculates the earliest visible event of the day, the choice being between moonrise and moonset, based on the location of the sun data source of index nSunSourceIndex of the current script.

 

Even though we are looking for moonrise and moonset, this function uses the Sun data source of the current script, not its Moon data source.

The moonrise or moonset is deemed to be visible if it occurs between sunset and sunrise (ie. at night).

A positive result means that the earliest event is a moonrise, a negative value means that it is a moonset.

The absolute value of the result is the time of the day expressed in one millionth of a day (less than 1/10th of a second).

 

Below is code that shows how to use of this function.

var
   nTimeTimesMillion sEventName sTime
begin
    // use the 1st Sun source on the date of the token
    nTimeTimesMillion = EarliestVisibleMoonRiseSet(n_TokenDate, 1)
    // get the type of event from the sign of the result
    if nTimeTimesMillion > 0
       sEventName = 'Moonrise at '
    else
       sEventName = 'Moonset at '
    endif
    // remove the sign from the result
    nTimeTimesMillion = Abs(nTimeTimesMillion)
    // convert time to a string, rounding to the nearest minute
    sTime = FormatTime('HH:nn', nTimeTimesMillion, true)
    sResult = sEventName + sTime
end

See also: Abs, FormatTime.

 


Topic 180120, last updated on 18-Apr-2020