|
|
@@ -190,13 +190,13 @@ public final class DateUtils { |
|
|
|
* moon period = 29.53058 days ~= 30, year = 365.2422 days |
|
|
|
* |
|
|
|
* days moon phase advances on first day of year compared to preceding year |
|
|
|
* = 365.2422 - 12*29.53058 ~= 11 |
|
|
|
* = 365.2422 - 12*29.53058 ~= 11 |
|
|
|
* |
|
|
|
* years in Metonic cycle (time until same phases fall on the same days of |
|
|
|
* the month) = 18.6 ~= 19 |
|
|
|
* the month) = 18.6 ~= 19 |
|
|
|
* |
|
|
|
* moon phase on first day of year (epact) ~= (11*(year%19) + 18) % 30 |
|
|
|
* (18 as initial condition for 1900) |
|
|
|
* (18 as initial condition for 1900) |
|
|
|
* |
|
|
|
* current phase in days = first day phase + days elapsed in year |
|
|
|
* |
|
|
@@ -213,10 +213,10 @@ public final class DateUtils { |
|
|
|
public static int getPhaseOfMoon(Calendar cal) { |
|
|
|
int dayOfTheYear = cal.get(Calendar.DAY_OF_YEAR); |
|
|
|
int yearInMetonicCycle = ((cal.get(Calendar.YEAR) - 1900) % 19) + 1; |
|
|
|
int epact = (11 * yearInMetonicCycle + 18) % 30; |
|
|
|
if ((epact == 25 && yearInMetonicCycle > 11) || epact == 24) { |
|
|
|
int epact = (11 * yearInMetonicCycle + 18) % 30; |
|
|
|
if ((epact == 25 && yearInMetonicCycle > 11) || epact == 24) { |
|
|
|
epact++; |
|
|
|
} |
|
|
|
return (((((dayOfTheYear + epact) * 6) + 11) % 177) / 22) & 7; |
|
|
|
return (((((dayOfTheYear + epact) * 6) + 11) % 177) / 22) & 7; |
|
|
|
} |
|
|
|
} |