int = SunEarliestLatestSunrise(nDate, nSunDataSourceIndex)
This macro function checks if the date nDate corresponds to the earliest or latest sunrise of the year, based on the observer position corresponding to the Sun data source of index nSunDataSourceIndex.
•The result is 1 for the earliest sunrise of the year and 2 for the latest sunrise of the year.
•If nDate does not correspond to the latest or earliest sunrise of the year, then the function returns 0.
The macro code below displays which of the earliest/latest sunrise/sunsets occur on nDate, if any.
sResult = ''
switch SunEarliestLatestSunrise(n_TokenDate, 1)
case 1
sResult = 'Earliest sunrise in ' + IntToStr(n_TokenYear)
case 2
sResult = 'Latest sunrise in ' + IntToStr(n_TokenYear)
endswitch
sBuffer = ''
switch SunEarliestLatestSunset(n_TokenDate, 1)
case 1
sBuffer = 'Earliest sunset in ' + IntToStr(n_TokenYear)
case 2
sBuffer = 'Latest sunset in ' + IntToStr(n_TokenYear)
endswitch
if sBuffer <> ''
if sResult <> ''
sResult = sResult + ', '
endif
sResult = sResult + sBuffer
endif
Caveat
This function is intended for locations with a pronounced seasonal variation in daylight, where the earliest and latest sunrise occur near the solstices. It checks dates in January, June, July and December and is not intended to identify annual extrema at equatorial locations or where periods without sunrise or sunset occur.
Comparisons use local clock times, including daylight-saving adjustments. An annual extremum occurring outside the four checked months will not be detected.
See also: SunEarliestLatestSunset.
Topic 178535, last updated on 18-Nov-2026