A Flash Developer Resource Site

Results 1 to 1 of 1

Thread: new and full moon dates

  1. #1
    Registered User
    Join Date
    Apr 2001
    Location
    Akron OH, USA
    Posts
    4,841

    new and full moon dates

    I have a flash mobile project where I need to determine the date of the next new or full moon that occurs after the current date. This application will not connect to the internet for information, so the logic must be done within Flash. Since this is a mobile project, I am looking for a Flash 4 level (Flash Lite 1.1 compatible) coding solution that is not too complex.

    I found an algorithm that determines one of 8 lunar phases for the current date but I am not sure how helpful this will be for this particular problem. (I can modify this code for Flash 4 scripting)

    Code:
    function moon_phase(year,month,day)
    {
        /*
          calculates the moon phase (0-7), accurate to 1 segment.
          	0 = new moon.
    	1 = Waxing Crescent
    	2 = First Quarter
    	3 = Waxing Gibbous
          	4 = full moon.
    	5 = Waning Gibbous
    	6 = Last Quarter
    	7 = Waning Crescent
          */
        
        d = day;
        if (month == 2) d += 31;
        else if (month > 2) d += 59+(month-3)*30.6+0.5;
        g = (year-1900)%19;
        e = (11*g + 29) % 30;
        if (e == 25 || e == 24) ++e;
        return ((((e + d)*6+5)%177)/22 & 7);
    }
    This function seems to evaluate the current date based upon one of 8 positions within the lunar cycle. Is there a way to modify the function so that it evaluates for one of 29 positions in the lunar cycle (one for each day in the cycle)? Then I would know how may days away from current date the next new or full moon is.

    Any suggestions on how to approach this problem?
    Last edited by hp3; 01-09-2008 at 04:50 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center