Please enable JavaScript to view this site.

 

int = MoonPhaseAndTimeOf(nDate,nMoonSourceIndex,bUseEighths)

 

This macro function returns the index and time of the Moon phase that occurs on nDate.

 

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

 

The possible values returned by this function correspond to :

 

0

No moon phase of the type specified on nDate.

1

New Moon

2

Waxing Crescent

3

First Quarter

4

Waxing Gibbous

5

Full Moon

6

Waning Gibbous

7

Last quarter

8

Waning Crescent

 

The meaning of the result 0 depends on the value of the parameter bUseEighths.

 

If bUseEighths is false (the usual case) then a result of 0 means that there is no occurrence of any of the quarter moon phases on the current date, but it is still possible that an eighth phase occurs on nDate, because we specifically told Q++Studio to ignore the occurrence of eighth phases.

If bUseEighths is true then a result of 0 means that there is no occurrence of any of the quarter moon and no occurrence of any of the eighth phases occurs on nDate.

 

To separate the index and time, use the div and mod functions on the returned result, as shown in the code below.

nMoonIndex = 0
nPhaseAndTime = MoonPhaseAndTimeOf(nRunDate,1,false)
// do we have a phase ?
if (nPhaseAndTime > 0)
   nMoonIndex = nPhaseAndTime div 1000000
   nMoonTime = nPhaseAndTime mod 1000000
endif

The macro code below uses HeliacalEventOnDate in conjunction with MoonPhaseAndTimeOf, to look for the Maori New Year (Matariki), which corresponds to the new Moon which follows the heliacal rise of the Pleiades star cluster.

nEventType = 1 // heliacal rise
nAstroBody = 29 // Alcyone, the brightest star in the Pleiades
// look from mid-May to the end of June
nHeliacalDate = 0
for nRunDate = EncodeDate(nYear,5,15to EncodeDate(nYear,6,30)
   nHeliacalTime = HeliacalEventOnDate(nRunDate,1,nAstroBody,nEventType)
   if nHeliacalTime >= 0
      nHeliacalDate = nRunDate
      break // found it
   endif
endfor
Assert(nHeliacalDate > 0'heliacal event not found', true)
// now look for the new Moon that follows
nMatarikiDate = 0
for nRunDate = nHeliacalDate to EncodeDate(nYear,6,30)
   nNewMoonTime = MoonPhaseAndTimeOf(nRunDate,1,false)
   // do we have a phase and if so a new Moon ?
   if (nNewMoonTime > 0and (nNewMoonTime div 1000000 == 1)
      // if the new Moon is on the exact date of the heliacal rise
      // make sure that the time of the new Moon is after it
      if nRunDate == nHeliacalDate
         // New Moon must be after heliacal rise
         if (nNewMoonTime mod 1000000) > nHeliacalTime
            nMatarikiDate = nRunDate
            break // found it
         else
            // too early keep looking for the next new Moon
         endif
      else
         nMatarikiDate = nRunDate
         break // found it
      endif
   endif
endfor
Assert(nMatarikiDate > 0'Matariki not found', true)
// at the end
sResult = 'Maori New Year on ' + FormatDate('Dddd, Mmmmm d, yyyy', nMatarikiDate)

See also: MoonPhaseName and MoonPhaseSymbol.

 


Topic 177660, last updated on 18-Apr-2020