int = LunarEclipseOnDate(nDate, nSunDataSourceIndex, bOnlyIfVisible)
This macro function calculates the type and time of the lunar eclipse, as seen from any location on Earth, on nDate, using the Sun data source of index nSunDataSourceIndex.
•When an eclipse is found, the result combines its type index and time: eclipse type index × 1000000 + time in millionths of a day. One millionth of a day is less than 1/10th of a second. Use div 1000000 to extract the type index and mod 1000000 to extract the time.
•If no lunar eclipse occurs on nDate, then the function returns -1.
If bOnlyIfVisible is true, the function returns an eclipse only if the Moon is above the horizon at the time of maximum eclipse at the selected location. Otherwise, it returns -1. If bOnlyIfVisible is false, this visibility test is not applied..
Example
To separate the type of eclipse from the time, use the div and mod operators on the returned result, as shown in the code below.
nComboResult = LunarEclipseOnDate(n_TokenDate, 1, false)
if nComboResult >= 0
nEclipseType = nComboResult div 1000000
sEclipseTypeName = LunarEclipseTypeName(nEclipseType)
nEclipseTime = nComboResult mod 1000000
sEclipseTime = FormatTime('hh:nn', nEclipseTime, true)
sResult = sEclipseTypeName + ' lunar eclipse at ' + sEclipseTime
else
sResult = 'No lunar eclipse today'
endif
See also: LunarEclipseTypeName, LunarOccultationOnDate, SolarEclipseOnDate, Lunar Eclipse Types.
Topic 180035, last updated on 11-Oct-2026