MoonPhase 2.0 Lunar knowledge of any date and time



First update in under 12 hours. This provides information on the current lunar phase based on the time and date it is requested, OR based on any date in history or in the future. The computation is done on the device, no API’s are called.


Index returns a number of or between 0 and 7.

  • 0 new moon,
  • 1 waxing crescent,
  • 2 first quarter,
  • 3 waxing gibbous,
  • 4 full moon,
  • 5 waning gibbous,
  • 6 last quarter,
  • 7 waning crescent.

Current moon phase gives a percentage of illumination of the lunar surface.

The age of the moon returns how old the moon is in its current lunar cycle.

These next blocks are a little Kepler calculation to tell you what the speed and orbital distance of a planet would be, if you changed the mass of the sun, and changed how long a “year” would be. It returns the Distance, and Velocity of the planet.


Index returns an integer, Phase returns a number with decimal points (technically it could be a negative -99.99 – 0 – 99.99.

Age returns a String with a description.

Here are all three blocks in action with some labels

For the blocks on any custom date, everything is number based. No dashes etc.

For the Orbital Calculator, please ensure the mass of the sun does not exceed 200x. That would collapse the solar system and I like our solar system as it is thank you!

Download .

MoonPhase.aix (21.8 KB)


Maybe what you can do for the Lunar index is:

switch (lunarIndex) {
    case 0:
        return "New moon";
    case 1:
        return "Waxing crescent";
    case 2:
        return "First quarter";
    case 3:
        return "Waxing gibbous";
    case 4:
        return "Full moon";
    case 5:
        return "Waning gibbous";
    case 6:
        return "Last quarter";
    case 7:
        return "Waning crescent";

I learned this switch-case technique from @Monexy_28


Well I specifically did not do it like that because I wanted people to be able to use their own graphics if they wanted.

switch-case technique is cool.


What graphics are you using? You just convert it to a string for easier output so the users don’t have to keep coming back to a topic?


If (num == 0 ) image = newmoon.png ;

is alot easier then

if (string =“New moon”) image = newmoon.png.;

Thats the way I did it, and that is why.


You could use this:

By changing “i” parameter (0 to 1) you change the illuminated surface of the moon.
By changing “r” parameter (0 to 1) you change the rotation of the image.


Also, that way the extension will be more international language friendly.
@MeteorCoder Spoon feeding the user is not always a good idea.