'=========================================================================== ' Subject: CALCULATE MOON AGE Date: 07-15-97 (16:03) ' Author: Tika Carr Code: QB, QBasic, PDS ' Origin: t.carr@pobox.com Packet: ALGOR.ABC '=========================================================================== ' MOON_AGE.BAS ' ' Converted to QuickBasic by Tika Carr 7/14/1997 ' Original MOON_AGE.C public domain by Michelangelo Jones, 1:1/124. ' Found in Bob Stout's C SNIPPETS collection ' ' Public Domain - No warranties or guarantees are expressed nor implied. ' Returns 0 for new moon, 15 for full moon, ' 29 for the day before new, and so forth. ' ' This routine sometimes gets "off" by a few days, ' but is self-correcting. DECLARE FUNCTION MoonAge% (month%, day%, year%) DEFINT A-Z MoonData1: DATA 18, 0, 11, 22, 3, 14, 25, 6, 17, 28, 9, 20, 1, 12, 23, 4, 15, 26, 7 DATA -1, 1, 0, 1, 2, 3, 4, 5, 7, 7, 9, 9 MoonData2: DATA "new" : ' totally dark DATA "waxing crescent" : ' increasing to full & quarter light DATA "in its first quarter" : ' increasing to full & half light DATA "waxing gibbous" : ' increasing to full & > than half DATA "full" : ' fully lighted DATA "waning gibbous" : ' decreasing from full & > than half DATA "in its last quarter" : ' decreasing from full & half light DATA "waning crescent" : ' decreasing from full & quarter light DATA "Jan", "Feb", "Mar", "Apr", "May", "Jun" DATA "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" DIM description(8) AS STRING, months(12) AS STRING RESTORE MoonData2 FOR i = 0 TO 7: READ description(i): NEXT FOR i = 0 TO 11: READ months(i): NEXT CLS INPUT "Month (01 - 12): ", month INPUT "Day: ", day INPUT "year: ", year 'For the next line, you may want to fix this to take the year 2000 into 'consideration ;) IF year < 100 THEN year = year + 1900 phase = MoonAge(month, day, year) PRINT "Moon Age for "; month; "/"; day; "/"; year; ": "; phase PRINT "Moon phase on "; day; " "; months(month - 1); " "; year; " is "; PRINT description(INT(((phase + 2) * 16& / 59&))) FUNCTION MoonAge (month, day, year) STATIC DIM ages(19), offsets(12) RESTORE MoonData1 FOR i = 0 TO 18: READ ages(i): NEXT FOR i = 0 TO 11: READ offsets(i): NEXT IF day = 31 THEN day = 1 MoonAge = ((ages((year + 1) MOD 19) + ((day + offsets(month - 1)) MOD 30) + (year < 1900)) MOD 30) END FUNCTION