The text is created using mphase.c which was built on code from Calendrical Calculations written by Nachum Dershowitz and Edward M. Reingold.
To get the current angle between sun, earth, and moon you can use moonpos.c which was built on the same code as above.