bool = SunIsUp(nDate, nTimeOfDay, nSunDataSourceIndex)
This macro function checks if the Sun is up on the date nDate at nTimeOfDay for the Sun data source of position nSunDataSourceIndex.
➢The time is added to nDate as a fraction of a day. Negative values therefore refer to the preceding date, and values of 1000000 or more refer to the following date or later.
➢The parameter nTimeOfDay should be supplied in one millionth of a day (less than 1/10th of a second), using the function MillionFromHMS to avoid any error.
➢This macro function returns true when the Sun’s apparent center is more than 50 arc-minutes (approximately 0.8333°) above the horizon, so the entire solar disc is above the horizon. Apparent altitude includes atmospheric refraction. This is a stricter condition than the Sun merely having risen.
The macro code below checks if the Sun was up 5 minutes before moonset on the 29th day of the month of Ramadan, to determine (in Saudi Arabia and many other countries), if the next day will be the first day of the month of Shawal, also known as the End of Ramadan.
// get the current islamic year
nIslamicYear = iYearOf(n_TokenDate)
// when is the 29th of Ramadan ?
nRamadan29 = EncodeMuslimDate(nIslamicYear,9,29)
// when does the Moon set on that day ?
nTimeMoonset = MoonRiseSetTimeOf(nRamadan29,1,2)
Assert(nTimeMoonset >= 0, 'No moonset occurs on the requested date', true)
// check if the Sun was still up 5 minutes before
nTimeThreshold = nTimeMoonset - MillionFromHMS(0,5,0)
if SunIsUp(nRamadan29,nTimeThreshold,1)
sResult = 'Tomorrow is the 30th of Ramadan'
else
sResult = 'Tomorrow is the feast of the End of Ramadan'
endif
Note that the function SunIsUp uses the apparent position of the Sun, which takes into account atmospheric refraction, and therefore is closest to what a human observer would see.
See also: SunEarliestLatestSunrise, SunEarliestLatestSunset, SunRiseSetTimeOf.
Topic 179960, last updated on 11-Oct-2026