Announcing the Previous Calculation Core
Because the kernel was updated, greatly improving precision compared to the previously rough approach, the old calculations are posted here:
Calculation of the JD2000 value:
m_totaldays = ((((((367.0 * year) - Math.Floor((double) ((7.0 * (year + Math.Floor((double) ((month + 9.0) / 12.0)))) / 4.0))) - Math.Floor((double) ((3.0 * (Math.Floor((double) ((year + ((month - 9.0) / 7.0)) / 100.0)) + 1.0)) / 4.0))) + Math.Floor((double) ((275.0 * month) / 9.0))) + day) + 1721029.0) + (((hour + (minute / 60.0)) + ((second / 60.0) / 60.0)) / 24.0);
Calculation of Rahu:
double num = (jd - 2451545.0) / 36525.0;
double num2 = num * num;
double num3 = num * num2;
double num4 = ((125.04452 - (1934.136261 * num)) + (0.0020708 * num2)) + (num3 / 450000.0);
return (num4 * this.DegToRad);
Calculation of Yue Bei:
((263.2976 + ((360.0 * (jd - 2451543.5)) / 3230.9375)) % 360.0);
Full calculation code written long ago:
public class NongLi
{
private int cacheY;
private double D = 1.0;
private double DegToRad = 0.017453292519943295;
private double[] dts = new double[] {
-4000.0, 108371.7, -13036.8, 392.0, 0.0, -500.0, 17201.0, -627.82, 16.17, -0.3413, -150.0, 12200.6, -346.41, 5.403, -0.1593, 150.0,
9113.8, -328.13, -1.647, 0.0377, 500.0, 5707.5, -391.41, 0.915, 0.3145, 900.0, 2203.4, -283.45, 13.034, -0.1778, 1300.0, 490.1,
-57.35, 2.085, -0.0072, 1600.0, 120.0, -9.81, -1.532, 0.1403, 1700.0, 10.2, -0.91, 0.51, -0.037, 1800.0, 13.4, -0.72,
0.202, -0.0193, 1830.0, 7.8, -1.81, 0.416, -0.0247, 1860.0, 8.3, -0.13, -0.406, 0.0292, 1880.0, -5.4, 0.32, -0.183,
0.0173, 1900.0, -2.3, 2.06, 0.169, -0.0135, 1920.0, 21.2, 1.69, -0.304, 0.0167, 1940.0, 24.2, 1.22, -0.064, 0.0031,
1960.0, 33.2, 0.51, 0.231, -0.0109, 1980.0, 51.0, 1.29, -0.026, 0.0032, 2000.0, 64.7, -1.66, 5.224, -0.2905, 2150.0,
279.4, 732.95, 429.579, 0.0158, 6000.0
};
private static double[] E10 = new double[] { /* full E10 series retained from original; see source article */ };
private double[] E11, E12, E13, E14, E15, E20, E21, E30, E31, E32, E33;
private double EnnT;
private double[] GXC_e, GXC_l, GXC_p;
private double GXC_k;
private double h;
private double[] hcjjB = new double[] { 84381.448, -46.815, -0.00059, 0.001813 };
private int inth = 12;
private int intm;
private int ints;
public int J2000 = 0x256859;
private string[] jqB;
private double m;
private double M = 1.0;
private double[] M10, M11, M12, M1n, M20, M21, M30, M31;
private double MnnT;
private double[] nutB, preceB;
private double rad = 206264.80624709636;
private double RAD = 57.295779513082323;
private double s;
private double Y = 2000.0;
private string[] yueMing;
public YearJieQi CurrentYearJieQi;
public SolarTime[] SolarTerms24;
public LunarMonthDay1[] LunarMonthList;
public NongLi()
{
/* Full E/M coefficient tables (E10–E33, M10–M31, nutB) are retained from the original source article. */
this.jqB = new string[] {
"Spring Equinox", "Qingming", "Grain Rain", "Start of Summer", "Grain Full", "Grain in Ear", "Summer Solstice", "Minor Heat", "Major Heat", "Start of Autumn", "Limit of Heat", "White Dew", "Autumn Equinox", "Cold Dew", "Frost Descent", "Start of Winter",
"Minor Snow", "Major Snow", "Winter Solstice", "Minor Cold", "Major Cold", "Start of Spring", "Rain Water", "Awakening of Insects"
};
this.yueMing = new string[] { "First", "Second", "Third", "Fourth", "Fifth", "Sixth", "Seventh", "Eighth", "Ninth", "Tenth", "Eleventh", "Twelfth" };
this.cacheY = -65535;
this.CurrentYearJieQi = new YearJieQi();
this.SolarTerms24 = new SolarTime[0x1a];
this.LunarMonthList = new LunarMonthDay1[13];
this.GXC_e = new double[] { 0.016708634, -4.2037E-05, -1.267E-07 };
this.GXC_p = new double[] { 102.93735 / this.RAD, 1.71946 / this.RAD, 0.00046 / this.RAD };
this.GXC_l = new double[] { 280.4664567 / this.RAD, 36000.76982779 / this.RAD, 0.0003032028 / this.RAD, 0.0 / this.RAD, 0.0 / this.RAD };
this.GXC_k = 20.49552 / this.rad;
}
private void addGxc(double t, double[] zb)
{
double num = t / 36525.0;
double num2 = num * num;
double num3 = num2 * num;
double num4 = num3 * num;
double num5 = (((this.GXC_l[0] + (this.GXC_l[1] * num)) + (this.GXC_l[2] * num2)) + (this.GXC_l[3] * num3)) + (this.GXC_l[4] * num4);
double num6 = (this.GXC_p[0] + (this.GXC_p[1] * num)) + (this.GXC_p[2] * num2);
double num7 = (this.GXC_e[0] + (this.GXC_e[1] * num)) + (this.GXC_e[2] * num2);
double d = num5 - zb[0];
double num9 = num6 - zb[0];
zb[0] -= (this.GXC_k * (Math.Cos(d) - (num7 * Math.Cos(num9)))) / Math.Cos(zb[1]);
zb[1] -= (this.GXC_k * Math.Sin(zb[1])) * (Math.Sin(d) - (num7 * Math.Sin(num9)));
zb[0] = this.rad2mrad(zb[0]);
private void addPrece(double jd, double[] zb)
{
double num2 = 1.0;
double num3 = 0.0;
double num4 = jd / 365250.0;
for (int i = 1; i < 8; i++)
{
num2 *= num4;
num3 += this.preceB[i] * num2;
}
zb[0] = this.rad2mrad(zb[0] + ((num3 + (2.9965 * num4)) / this.rad));
public void Compute(int y)
{
if (this.cacheY != y)
{
int num;
this.cacheY = y;
double[] numArray = new double[14];
double[] numArray2 = new double[14];
double[] numArray3 = new double[14];
double num2 = (365.24219879 * (y - 0x7d0)) - 50.0;
for (num = 0; num < 14; num++)
{
numArray[num] = this.jiaoCal(num2 + (num * 30.4), (double) ((num * 30) - 90), 0.0);
numArray2[num] = this.jiaoCal(num2 + (num * 30.4), (double) ((num * 30) - 0x69), 0.0);
}
double num3 = (numArray[0] + 1.0) - this.Dint_dec(numArray[0], 8.0, false);
numArray3[0] = this.jiaoCal(num3, 0.0, 1.0);
for (num = 1; num < 14; num++)
{
numArray3[num] = this.jiaoCal(numArray3[num - 1] + 25.0, 0.0, 1.0);
}
double[] numArray4 = new double[14];
double[] numArray5 = new double[14];
double[] numArray6 = new double[14];
for (num = 0; num < 14; num++)
{
numArray4[num] = this.Dint_dec(numArray[num], 8.0, true);
numArray5[num] = this.Dint_dec(numArray2[num], 8.0, true);
numArray6[num] = this.Dint_dec(numArray3[num], 8.0, true);
}
double num4 = 13.0;
double num5 = -1.0;
int[] numArray7 = new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 0, 0 };
string[] strArray = new string[numArray7.Length];
if (numArray6[12] <= numArray4[12])
{
numArray7[12] = 12;
num4 = 13.0;
num = 1;
while (num < 13)
{
if (numArray6[num] <= numArray4[num])
{
break;
}
num++;
}
num5 = num - 1;
while (num < 13)
{
numArray7[num - 1]--;
num++;
}
}
num = 0;
while (num < num4)
{
this.LunarMonthList[num] = new LunarMonthDay1();
strArray[num] = this.yueMing[(numArray7[num] + 10) % 12];
this.LunarMonthList[num].Yueming = (numArray7[num] + 10) % 12;
if (num == num5)
{
this.LunarMonthList[num].isRun = true;
}
else
{
this.LunarMonthList[num].isRun = false;
}
if ((numArray6[num + 1] - numArray6[num]) > 29.0)
{
this.LunarMonthList[num].isLong = true;
}
else
{
this.LunarMonthList[num].isLong = false;
}
num++;
}
for (num = 0; num < num4; num++)
{
int num1 = ((num * 2) + 0x12) % 0x18;
int num6 = ((num * 2) + 0x11) % 0x18;
this.setFromJD((numArray2[num] + this.J2000) + 0.33333333333333331, true);
this.SolarTerms24[2 * num] = new SolarTime((int) this.Y, (int) this.M, (int) this.D, (int) this.h, (int) this.m, (int) this.s);
this.CurrentYearJieQi.SetJieQiByIndex((2 * num) - 1, new SolarTime((int) this.Y, (int) this.M, (int) this.D, (int) this.h, (int) this.m, (int) this.s));
this.setFromJD((numArray[num] + this.J2000) + 0.33333333333333331, true);
this.SolarTerms24[(2 * num) + 1] = new SolarTime((int) this.Y, (int) this.M, (int) this.D, (int) this.h, (int) this.m, (int) this.s);
this.CurrentYearJieQi.SetJieQiByIndex(2 * num, new SolarTime((int) this.Y, (int) this.M, (int) this.D, (int) this.h, (int) this.m, (int) this.s));
this.setFromJD((numArray3[num] + this.J2000) + 0.33333333333333331, true);
this.toJD(false);
this.LunarMonthList[num].datetime = new SolarTime((int) this.Y, (int) this.M, (int) this.D, (int) this.h, (int) this.m, (int) this.s);
private double deltatT(double y)
{
double[] dts = this.dts;
int index = 0;
while (index < 100)
{
if ((y < dts[index + 5]) || (index == 0x5f))
{
break;
}
index += 5;
}
double num2 = ((y - dts[index]) / (dts[index + 5] - dts[index])) * 10.0;
double num3 = num2 * num2;
double num4 = num3 * num2;
return (((dts[index + 1] + (dts[index + 2] * num2)) + (dts[index + 3] * num3)) + (dts[index + 4] * num4));
private double deltatT2(double jd)
{
return (this.deltatT((jd / 365.2425) + 2000.0) / 86400.0);
private double Dint_dec(double jd, double shiqu, bool int_dec)
{
double d = ((jd + 0.5) - this.deltatT2(jd)) + (shiqu / 24.0);
if (int_dec)
{
return Math.Floor(d);
return (d - Math.Floor(d));
public double[] earCal(double jd)
{
this.EnnT = jd / 365250.0;
double[] numArray = new double[3];
double ennT = this.EnnT;
double num2 = ennT * ennT;
double num3 = num2 * ennT;
double num4 = num3 * ennT;
double num5 = num4 * ennT;
numArray[0] = ((((this.Enn(E10) + (this.Enn(this.E11) * ennT)) + (this.Enn(this.E12) * num2)) + (this.Enn(this.E13) * num3)) + (this.Enn(this.E14) * num4)) + (this.Enn(this.E15) * num5);
numArray[1] = this.Enn(this.E20) + (this.Enn(this.E21) * ennT);
numArray[2] = ((this.Enn(this.E30) + (this.Enn(this.E31) * ennT)) + (this.Enn(this.E32) * num2)) + (this.Enn(this.E33) * num3);
numArray[0] = this.rad2mrad(numArray[0]);
return numArray;
private double Enn(double[] E)
{
double num = 0.0;
for (int i = 0; i < E.Length; i += 3)
{
num += E[i] * Math.Cos(E[i + 1] + (this.EnnT * E[i + 2]));
return num;
public SolarTime GetDate()
{
return new SolarTime((int) this.Y, (int) this.M, (int) this.D, (int) this.h, (int) this.m, (int) this.s);
public SolarTime GetDateFromJD2000(double jd)
{
jd += 2451545.5;
double num = this.int2(jd);
double v = jd - num;
if (num > 2299161.0)
{
double num3 = this.int2((num - 1867216.25) / 36524.25);
num += (1.0 + num3) - this.int2(num3 / 4.0);
num += 1524.0;
double num4 = this.int2((num - 122.1) / 365.25);
double num5 = num - this.int2(365.25 * num4);
double num6 = this.int2(num5 / 30.6001);
num5 -= this.int2(num6 * 30.6001);
num4 -= 4716.0;
num6--;
if (num6 > 12.0)
{
num6 -= 12.0;
if (num6 <= 2.0)
{
num4++;
v *= 24.0;
double num7 = this.int2(v);
v -= num7;
v *= 60.0;
double num8 = this.int2(v);
v -= num8;
v *= 60.0;
double num9 = v;
return new SolarTime((int) num4, (int) num6, (int) num5, (int) num7, (int) num8, (int) num9);
public double GetDays(double y, double m, double d, double hour, double min, double sec)
{
return (((((((((367.0 * y) - Math.Floor((double) ((7.0 * (y + Math.Floor((double) ((m + 9.0) / 12.0)))) / 4.0))) - Math.Floor((double) ((3.0 * (Math.Floor((double) ((y + ((m - 9.0) / 7.0)) / 100.0)) + 1.0)) / 4.0))) + Math.Floor((double) ((275.0 * m) / 9.0))) + d) + (hour / 24.0)) + ((min / 60.0) / 24.0)) + (((sec / 60.0) / 60.0) / 24.0)) + 1721028.5);
public SolarTime GetSunChuDateTime(double jd, double lat, double lng)
{
double num = jd - this.J2000;
double l = 0.0 - (((((int) lat) + (((lat % 1.0) * 100.0) / 60.0)) / 180.0) * 3.1415926535897931);
double fa = ((((int) lng) + (((lng % 1.0) * 100.0) / 60.0)) / 180.0) * 3.1415926535897931;
double num4 = this.SunSheng(num, l, fa, 0.33333333333333331);
return this.GetDateFromJD2000(num4);
public SolarTime GetSunChuDateTime(SolarTime dt, double lat, double lng)
{
return this.GetSunChuDateTime(dt.TotalDays, lat, lng);
private void HCconv(double[] JW, double E)
{
double a = this.rad2mrad(JW[0]);
double num2 = JW[1];
double num3 = Math.Sin(E);
double num4 = Math.Cos(E);
double d = (num4 * Math.Sin(num2)) + ((num3 * Math.Cos(num2)) * Math.Sin(a));
double v = Math.Atan2((Math.Sin(a) * num4) - (Math.Tan(num2) * num3), Math.Cos(a));
JW[0] = this.rad2mrad(v);
JW[1] = Math.Asin(d);
private double hcjj1(double t)
{
double num = t / 36525.0;
double num2 = num * num;
double num3 = num2 * num;
return ((((this.hcjjB[0] + (this.hcjjB[1] * num)) + (this.hcjjB[2] * num2)) + (this.hcjjB[3] * num3)) / this.rad);
private double int2(double v)
{
v = Math.Floor(v);
if (v < 0.0)
{
return (v + 1.0);
return v;
private double jiaoCai(double lx, double t, double jiao)
{
double[] zb = this.earCal(t);
zb[0] += 3.1415926535897931;
zb[1] = -zb[1];
this.addGxc(t, zb);
if (lx == 0.0)
{
NongLi.CustomD customd = this.nutation(t);
zb[0] += customd.Lon;
return this.rad2mrad(jiao - zb[0]);
double[] numArray2 = this.moonCal(t);
return this.rad2mrad(jiao - (numArray2[0] - zb[0]));
private double jiaoCal(double t1, double jiao, double lx)
{
double t = t1;
double num2 = 0.0;
if (lx == 0.0)
{
t += 360.0;
else
{
t += 25.0;
jiao *= 0.017453292519943295;
double num4 = this.jiaoCai(lx, t1, jiao);
double num5 = this.jiaoCai(lx, t, jiao);
if (num4 < num5)
{
num5 -= 6.2831853071795862;
double num6 = 1.0;
for (int i = 0; i < 10; i++)
{
double num7 = (num5 - num4) / (t - t1);
if (Math.Abs(num7) > 1E-15)
{
num6 = num7;
num2 = t1 - (num4 / num6);
double num3 = this.jiaoCai(lx, num2, jiao);
if (num3 > 1.0)
{
num3 -= 6.2831853071795862;
if (Math.Abs(num3) < 1E-08)
{
return num2;
t1 = t;
num4 = num5;
t = num2;
num5 = num3;
return num2;
private double Mnn(double[] F)
{
double num2 = 0.0;
double mnnT = this.MnnT;
double num4 = mnnT * mnnT;
double num5 = num4 * mnnT;
double num6 = num5 * mnnT;
for (int i = 0; i < F.Length; i += 6)
{
num2 += F[i] * Math.Sin((((F[i + 1] + (mnnT * F[i + 2])) + (num4 * F[i + 3])) + (num5 * F[i + 4])) + (num6 * F[i + 5]));
return num2;
private double[] moonCal(double jd)
{
this.MnnT = jd / 36525.0;
double mnnT = this.MnnT;
double num2 = mnnT * mnnT;
double num3 = num2 * mnnT;
double num4 = num3 * mnnT;
double[] zb = new double[] { ((this.Mnn(this.M10) + (this.Mnn(this.M11) * mnnT)) + (this.Mnn(this.M12) * num2)) / this.rad, (this.Mnn(this.M20) + (this.Mnn(this.M21) * mnnT)) / this.rad, (this.Mnn(this.M30) + (this.Mnn(this.M31) * mnnT)) * 0.999999949827 };
zb[0] = ((((zb[0] + this.M1n[0]) + (this.M1n[1] * mnnT)) + (this.M1n[2] * num2)) + (this.M1n[3] * num3)) + (this.M1n[4] * num4);
zb[0] = this.rad2mrad(zb[0]);
this.addPrece(jd, zb);
return zb;
private double[] moonCal2(double jd)
{
double[] numArray = this.moonCal(jd);
NongLi.CustomD customd = this.nutation(jd);
numArray[0] = this.rad2mrad(numArray[0] + customd.Lon);
return numArray;
private double[] moonCal3(double jd)
{
double[] jW = this.moonCal(jd);
this.HCconv(jW, this.hcjj1(jd));
this.nutationRaDec(jd, jW);
return jW;
private CustomD nutation(double t)
{
NongLi.CustomD customd = new NongLi.CustomD { Lon = 0.0, obl = 0.0 };
t /= 36525.0;
double num3 = t;
double num4 = num3 * num3;
double num5 = num4 * num3;
double num6 = num5 * num3;
for (int i = 0; i < this.nutB.Length; i += 9)
{
double a = (((this.nutB[i] + (this.nutB[i + 1] * num3)) + (this.nutB[i + 2] * num4)) + (this.nutB[i + 3] * num5)) + (this.nutB[i + 4] * num6);
customd.Lon += (this.nutB[i + 5] + ((this.nutB[i + 6] * t) / 10.0)) * Math.Sin(a);
customd.obl += (this.nutB[i + 7] + ((this.nutB[i + 8] * t) / 10.0)) * Math.Cos(a);
customd.Lon /= this.rad * 10000.0;
customd.obl /= this.rad * 10000.0;
return customd;
private void nutationRaDec(double t, double[] zb)
{
double d = zb[0];
double a = zb[1];
double num3 = this.hcjj1(t);
double num4 = Math.Sin(num3);
double num5 = Math.Cos(num3);
NongLi.CustomD customd = this.nutation(t);
double num6 = Math.Cos(d);
double num7 = Math.Sin(d);
double num8 = Math.Tan(a);
zb[0] += ((num5 + ((num4 * num7) * num8)) * customd.Lon) - ((num6 * num8) * customd.obl);
zb[1] += ((num4 * num6) * customd.Lon) + (num7 * customd.obl);
zb[0] = this.rad2mrad(zb[0]);
public string paiYue(int y)
{
int num;
double[] numArray = new double[14];
double[] numArray2 = new double[14];
double[] numArray3 = new double[14];
double num2 = (365.24219879 * (y - 0x7d0)) - 50.0;
for (num = 0; num < 14; num++)
{
numArray[num] = this.jiaoCal(num2 + (num * 30.4), (double) ((num * 30) - 90), 0.0);
numArray2[num] = this.jiaoCal(num2 + (num * 30.4), (double) ((num * 30) - 0x69), 0.0);
double num3 = (numArray[0] + 1.0) - this.Dint_dec(numArray[0], 8.0, false);
numArray3[0] = this.jiaoCal(num3, 0.0, 1.0);
for (num = 1; num < 14; num++)
{
numArray3[num] = this.jiaoCal(numArray3[num - 1] + 25.0, 0.0, 1.0);
double[] numArray4 = new double[14];
double[] numArray5 = new double[14];
double[] numArray6 = new double[14];
for (num = 0; num < 14; num++)
{
numArray4[num] = this.Dint_dec(numArray[num], 8.0, true);
numArray5[num] = this.Dint_dec(numArray2[num], 8.0, true);
numArray6[num] = this.Dint_dec(numArray3[num], 8.0, true);
double num4 = 12.0;
double num5 = -1.0;
int[] numArray7 = new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 0, 0 };
string[] strArray = new string[numArray7.Length];
if (numArray6[12] <= numArray4[12])
{
numArray7[12] = 12;
num4 = 13.0;
num = 1;
while (num < 13)
{
if (numArray6[num] <= numArray4[num])
{
break;
num++;
num5 = num - 1;
while (num < 13)
{
numArray7[num - 1]--;
num++;
num = 0;
while (num < num4)
{
strArray[num] = this.yueMing[(numArray7[num] + 10) % 12];
if (num == num5)
{
string[] strArray2;
IntPtr ptr;
(strArray2 = strArray)[(int) (ptr = (IntPtr) num)] = strArray2[(int) ptr] + "Leap ";
else
{
string[] strArray3;
IntPtr ptr2;
(strArray3 = strArray)[(int) (ptr2 = (IntPtr) num)] = strArray3[(int) ptr2] + "th Month";
if ((numArray6[num + 1] - numArray6[num]) > 29.0)
{
string[] strArray4;
IntPtr ptr3;
(strArray4 = strArray)[(int) (ptr3 = (IntPtr) num)] = strArray4[(int) ptr3] + " (Long)";
else
{
string[] strArray5;
IntPtr ptr4;
(strArray5 = strArray)[(int) (ptr4 = (IntPtr) num)] = strArray5[(int) ptr4] + " (Short)";
num++;
string str = "Jieqi Watch Time Zhongqi Watch Time Lunar Month Watch Time of New Moon\r\n";
for (num = 0; num < num4; num++)
{
int index = ((num * 2) + 0x12) % 0x18;
int num7 = ((num * 2) + 0x11) % 0x18;
this.setFromJD((numArray2[num] + this.J2000) + 0.33333333333333331, true);
string str2 = str;
str = str2 + this.jqB[num7] + ":" + this.toStr() + " ";
this.setFromJD((numArray[num] + this.J2000) + 0.33333333333333331, true);
string str3 = str;
str = str3 + this.jqB[index] + ":" + this.toStr() + " ";
this.setFromJD((numArray3[num] + this.J2000) + 0.33333333333333331, true);
string str4 = str;
str = str4 + strArray[num] + ":" + this.toStr() + "\r\n";
Console.WriteLine(str);
return str;
private double rad2mrad(double v)
{
v = v % 6.2831853071795862;
if (v < 0.0)
{
return (v + 6.2831853071795862);
if (v > 3.1415926535897931)
{
return (v - 6.2831853071795862);
return v;
public void setFromJD(double jd, bool UTC)
{
double num3;
if (UTC)
{
jd -= this.deltatT2(jd - this.J2000);
jd += 0.5;
double num = this.int2(jd);
double v = jd - num;
if (num > 2299161.0)
{
num3 = this.int2((num - 1867216.25) / 36524.25);
num += (1.0 + num3) - this.int2(num3 / 4.0);
num += 1524.0;
this.Y = this.int2((num - 122.1) / 365.25);
num3 = num - this.int2(365.25 * this.Y);
this.M = this.int2(num3 / 30.6001);
this.D = num3 - this.int2(this.M * 30.6001);
this.Y -= 4716.0;
this.M--;
if (this.M > 12.0)
{
this.M -= 12.0;
if (this.M <= 2.0)
{
this.Y++;
v *= 24.0;
this.h = this.int2(v);
v -= this.h;
v *= 60.0;
this.m = this.int2(v);
v -= this.m;
v *= 60.0;
this.s = v;
public double[] sunCal2(double jd)
{
double[] zb = this.earCal(jd);
zb[0] += 3.1415926535897931;
zb[1] = -zb[1];
NongLi.CustomD customd = this.nutation(jd);
zb[0] = this.rad2mrad(zb[0] + customd.Lon);
this.addGxc(jd, zb);
return zb;
private double sunLat(double t)
{
t += ((((32.0 * (t + 1.8)) * (t + 1.8)) - 20.0) / 86400.0) / 36525.0;
double num = (((((48950621.66 + (6283319653.318 * t)) + ((53.0 * t) * t)) - 994.0) + (334166.0 * Math.Cos(4.669257 + (628.307585 * t)))) + (3489.0 * Math.Cos(4.6261 + (1256.61517 * t)))) + ((2060.6 * Math.Cos(2.67823 + (628.307585 * t))) * t);
return (num / 10000000.0);
private double SunSheng(double jd, double L, double fa, double TZ)
{
jd -= TZ;
double t = jd / 36525.0;
double a = this.sunLat(t);
double num3 = Math.Sin(a);
double x = Math.Cos(a);
double num5 = (6.2831853071795862 * (0.779057273264 + (1.0027378119113546 * jd))) + (((0.014506 + (4612.15739966 * t)) + ((1.39667721 * t) * t)) / this.rad);
double d = (84381.406 - (46.836769 * t)) / this.rad;
double num7 = Math.Atan2(num3 * Math.Cos(d), x);
double num8 = Math.Asin(Math.Sin(d) * num3);
double num9 = (Math.Sin(-3000.0 / this.rad) - (Math.Sin(fa) * Math.Sin(num8))) / (Math.Cos(fa) * Math.Cos(num8));
if ((num9 >= 1.0) || (num9 <= -1.0))
{
return 0.0;
double num10 = -Math.Acos(num9);
double num11 = (num5 - L) - num7;
return ((jd - (this.rad2mrad(num11 - num10) / 6.28)) + TZ);
private double toJD(bool UTC)
{
double y = this.Y;
double m = this.M;
double num3 = 0.0;
if (m <= 2.0)
{
m += 12.0;
y--;
if ((((this.Y * 372.0) + (this.M * 31.0)) + this.D) >= 588829.0)
{
num3 = this.int2(y / 100.0);
num3 = (2.0 - num3) + this.int2(num3 / 4.0);
num3 += this.int2(365.2500001 * (y + 4716.0));
num3 += this.int2(30.6 * (m + 1.0)) + this.D;
num3 += (((((this.s / 60.0) + this.m) / 60.0) + this.h) / 24.0) - 1524.5;
if (UTC)
{
return (num3 + this.deltatT2(num3 - this.J2000));
return num3;
private string toStr()
{
string str = " " + this.Y;
string str2 = "0" + this.M;
string str3 = "0" + this.D;
string str4 = this.h.ToString();
string str5 = this.m.ToString();
string str6 = Math.Floor((double) (this.s + 0.5)).ToString();
if (this.s >= 60.0)
{
this.s -= 60.0;
this.m++;
if (this.m >= 60.0)
{
this.m -= 60.0;
this.h++;
str4 = "0" + str4;
str5 = "0" + str5;
str6 = "0" + str6;
str = str.Substring(str.Length - 5, 5);
str2 = str2.Substring(str2.Length - 2, 2);
str3 = str3.Substring(str3.Length - 2, 2);
str4 = str4.Substring(str4.Length - 2, 2);
str5 = str5.Substring(str5.Length - 2, 2);
str6 = str6.Substring(str6.Length - 2, 2);
return (str + "-" + str2 + "-" + str3 + " " + str4 + ":" + str5 + ":" + str6);
public double Rahu(double jd)
{
double num = (jd - 2451545.0) / 36525.0;
double num2 = num * num;
double num3 = num * num2;
double num4 = ((125.04452 - (1934.136261 * num)) + (0.0020708 * num2)) + (num3 / 450000.0);
return (num4 * this.DegToRad);
public double YueBei(double jd)
{
return ((263.2976 + ((360.0 * (jd - 2451543.5)) / 3230.9375)) % 360.0);
[StructLayout(LayoutKind.Sequential)]
public struct CustomD
{
public double Lon;
public double obl;
}