25const double Moon::RAD = (3.1415926535897/180.0);
53 int n = (int)(12.37*((year-1900)+((mon-0.5)/12.0)));
60 if(jd < nm_jd)
flmoon(--n,0,nm_jd,nm_frac);
67 if(abs((
int)jd - nm_jd) < abs((
int)jd - fq_jd)) {
69 ph = (double)(((
double)(jd) - ((
double)nm_jd+nm_frac)) * phase_per_day);
70 if(ph < 0) ph = 4.0 + ph;
71 return(ph > 4.0 ? ph - 4.0 : ph);
74 ph = 1.0+(double)(((
double)(jd) - ((
double)fq_jd+fq_frac)) * phase_per_day);
75 return(ph > 4.0 ? ph - 4.0 : ph);
84 if(abs((
int)jd - fq_jd) < abs((
int)jd - fm_jd)) {
86 ph = 1.0+(double)(((
double)(jd) - ((
double)fq_jd+fq_frac)) * phase_per_day);
87 return(ph > 4.0 ? ph - 4.0 : ph);
90 ph = 2.0+(double)(((
double)(jd) - ((
double)fm_jd+fm_frac)) * phase_per_day);
91 return(ph > 4.0 ? ph - 4.0 : ph);
100 if(abs((
int)jd - fm_jd) < abs((
int)jd - lq_jd)) {
102 ph = (2.0+(double)(((
double)(jd) - ((
double)fm_jd+fm_frac)) * phase_per_day));
103 return(ph > 4.0 ? ph - 4.0 : ph);
106 ph = (3.0+(double)(((
double)(jd) - ((
double)lq_jd+lq_frac)) * phase_per_day));
107 return(ph > 4.0 ? ph - 4.0 : ph);
111 flmoon(++n,0,nm_jd,nm_frac);
113 ph = (4.0+(double)(((
double)(jd) - ((
double)nm_jd+nm_frac)) * phase_per_day));
114 return(ph > 4.0 ? ph - 4.0 : ph);
126 int n = (int)(12.37*((year-1900)+((mon-0.5)/12.0)));
127 double intpart = 0.0;
130 djd =
flmoon(n,nph,ph_jd,frac) + 0.5;
132 djd =
flmoon(--n,nph,ph_jd,frac) + 0.5;
135 djd =
flmoon(++n,nph,ph_jd,frac) + 0.5;
142 tmpt = localtime(&e);
143 djd += ((double)tmpt->tm_gmtoff * (1.0/86400.0));
144 if(tmpt->tm_isdst) djd -= (1.0/24.0);
145 ph_jd = (long)floor(djd);
148 ph_jd = (long)floor(djd);
150 frac = djd - floor(djd);
154 hr = (int)(frac >= 0.0 ? floor(frac) : ceil(frac-1.0));
156 min = (int)floor(60*frac);
165 double lunar_cycles = n + ( nph / 4.0 );
167 double t = lunar_cycles / 1236.85;
171 double sun_anomaly = 359.2242 + ( 29.10535608 * lunar_cycles );
174 double moon_anomaly = 306.0253 + ( 385.81691806 * lunar_cycles ) + ( 0.010730 * t2 );
179 double xtra = 0.75933 + ( 1.53058868 * lunar_cycles ) + ( ( ( 1.78e-4 ) - ( 1.55e-7 ) * t ) * t2 );
185 jd = 2415020 + ( 28L * n ) + ( 7L * nph );
189 if(nph == 0 || nph == 2)
190 xtra += ( ( 0.1734-3.93e-4 * t ) * sin(
RAD*sun_anomaly) ) - ( 0.4068 * sin(
RAD*moon_anomaly) );
192 xtra += ( ( 0.1721-4.0e-4 * t ) * sin(
RAD*sun_anomaly) ) - ( 0.6280 * sin(
RAD*moon_anomaly) );
195 int_part = (int)( xtra >= 0.0 ? floor(xtra) : ceil(xtra-1.0) );
197 frac = xtra - int_part;
198 return double(jd + frac);
207 const long GREG = 2299161L;
215 a = (long)((((jd-1867216)-0.25)/36524.25));
216 a = (long)(jd+1+(
long)a-(long)(0.25*(
long)a));
221 c = (long)(6680+((b-2439870)-122.1)/365.25);
222 d = 365*c+(long)(0.25*c);
223 e = (long)((b-d)/30.6001);
224 day = (int)(b-d-(
long)(30.6001*e));
226 if(mon > 12) mon -= 12;
227 year = (int)(c-4715);
229 if(year <= 0) --year;
240 if(jy == 0)
return(0);
242 if(mon > 2) jm=mon+1;
247 jul = (long)(floor(365.25*jy)+floor(30.6001*jm)+day+1720995);
248 if(day+31L*(mon+12L*year) >=
IGREG) {
250 jul += 2-ja+(int)(0.25*ja);
263 return(
isDST(m,d,y));
276 tmpt = localtime(&e);
277 tmp.tm_gmtoff = tmpt->tm_gmtoff;
278 tmp.tm_mon = mon - 1;
280 tmp.tm_year = year - 1900;
286 tmpt = localtime(&e);
287 if(tmpt->tm_isdst)
return(
true);
static long Calendar2Julian(int mon, int day, int year)
static double flmoon(int n, int nph, long &jd, double &frac)
static const double RAD
Radians to degree convertion.
static double phase(int mon, int day, int year)
static void nextphase(int &mon, int &day, int &year, int &hr, int &min, int nph)
static const double MEAN_LUNAR_CYCLE
static bool isDST(long jd)
static void Julian2Calendar(long jd, int &mon, int &day, int &year)