代码在这里
http://home.comcast.net/~athomeprojects/build.html
问题是
现在我将org\athomeprojects\base\ChartData.java中
private Hashtable chineseCalendar(int[] date, String[] poles,
double[] sign_pos, int[] pole_override, int[] lunar_cal,
int[] solar_cal)
下的代码改为
private Hashtable chineseCalendar(int[] date, String[] poles,
double[] sign_pos, int[] pole_override, int[] lunar_cal,
int[] solar_cal)
{
int y, m1, m2, index;
String str;
int[] adj_date = (int[]) date.clone();
// around 12:00pm, it is the next day
int a0 = (int) (birth_sign_pos[SUN] / 30.0);
int b0 = (int) (life_sign_pos / 30.0);
int x0 = b0 - a0 + 3;
if (x0 < 0)
x0 += 12;
if (x0 >= 12)
x0 -= 12;
if (x0 < 3 && adj_date[3] > 17 && adj_date[3] < 24
&& Resource.getPrefInt("switch_day_at_11_pm") != 0)
BaseCalendar.addTime(adj_date, Calendar.DAY_OF_MONTH, 1);
if (x0 > 9 && adj_date[3] < 7
&& Resource.getPrefInt("switch_day_at_11_pm") != 0)
BaseCalendar.addTime(adj_date, Calendar.DAY_OF_MONTH, -1); 
if (lunar_cal != null) {
poles[CH_YEAR] = year_names[lunar_cal[0] - 1];
str = poles[CH_YEAR].substring(0, 1);
for (y = 0; y < sky_pole_names.length; y++) {
if (sky_pole_names[y].equals(str))
break;
}
index = lunar_cal[1] - 1;
m1 = index + month_sky_pole_shifts[y];
while (m1 >= sky_pole_names.length)
m1 -= sky_pole_names.length;
m2 = index + month_earth_pole_shift;
while (m2 >= earth_pole_names.length)
m2 -= earth_pole_names.length;
poles[CH_MONTH] = sky_pole_names[m1] + earth_pole_names[m2];
}
int offset = (pole_override != null) ? pole_override[0] : 0;
offset += lunar_cal[0] - 1;
poles[YEAR_POLE] = year_names[FileIO.boundNumber(offset,
year_names.length)];
index = lunar_cal[1] - 1;
str = poles[YEAR_POLE].substring(0, 1);
for (y = 0; y < sky_pole_names.length; y++) {
if (sky_pole_names[y].equals(str))
break;
}
m1 = index + month_sky_pole_shifts[y];
while (m1 >= sky_pole_names.length)
m1 -= sky_pole_names.length;
m2 = index + month_earth_pole_shift;
while (m2 >= earth_pole_names.length)
m2 -= earth_pole_names.length;
poles[MONTH_POLE] = sky_pole_names[m1] + earth_pole_names[m2];
offset = (pole_override != null) ? pole_override[1] : 0;
if (offset != 0) {
offset += FileIO.getArrayIndex(poles[MONTH_POLE], year_names);
poles[MONTH_POLE] = year_names[FileIO.boundNumber(offset,
year_names.length)];
}
day_pole_base[3] = adj_date[3];
day_pole_base[4] = adj_date[4];
offset = (pole_override != null) ? pole_override[2] : 0;
offset += cal.getDifferenceInDays(day_pole_base, adj_date);
poles[DAY_POLE] = year_names[FileIO.boundNumber(offset,
year_names.length)];
str = poles[DAY_POLE].substring(0, 1);
for (y = 0; y < sky_pole_names.length; y++) {
if (sky_pole_names[y].equals(str))
break;
}
// around 12:00pm and before 12:00am, sky pole is from next day
int a1 = (int) (birth_sign_pos[SUN] / 30.0);
int b1 = (int) (life_sign_pos / 30.0);
int x1 = b1 - a1 + 3;
if (x1 < 0)
x1 += 12;
if (x1 >= 12)
x1 -= 12;
if (x1 < 3 && adj_date[3] > 17 && adj_date[3] < 24
&& Resource.getPrefInt("switch_day_at_11_pm") == 0) {
if (++y == sky_pole_names.length)
y = 0;
}
if (x1 > 9 && adj_date[3] < 7
&& Resource.getPrefInt("switch_day_at_11_pm") == 0) {
if (--y == sky_pole_names.length)
y = 0;
}
int a = (int) (birth_sign_pos[SUN] / 30.0);
int b = (int) (life_sign_pos / 30.0);
int x = b - a;
if (x <= 0)
x += 12;
int z = x + 3;
if (z > 12)
z -= 12;
index = z;
while (index >= earth_pole_names.length)
index -= earth_pole_names.length;
m1 = index + hour_sky_pole_shifts[y];
while (m1 >= sky_pole_names.length)
m1 -= sky_pole_names.length;
m2 = index + hour_earth_pole_shift;
while (m2 >= earth_pole_names.length)
m2 -= earth_pole_names.length;
poles[HOUR_POLE] = sky_pole_names[m1] + earth_pole_names[m2];
offset = (pole_override != null) ? pole_override[3] : 0;
if (offset != 0) {
offset += FileIO.getArrayIndex(poles[HOUR_POLE], year_names);
poles[HOUR_POLE] = year_names[FileIO.boundNumber(offset,
year_names.length)];
}
return (sign_pos != null) ? getStarSigns(poles, sign_pos, false) : null;
}
使得八字日柱的运算规则变化了
现在的问题是
在org\athomeprojects\base\Calculate.java中
public int[] getLunarCalendar(int[] date, double[] solar_terms,
double[] new_moons)
下的阴历日期代码
lunar_date[2] = (int) (trimHour(jd) - trimHour(new_moons[index - 1])) + 1;
是根据trimHour定义的午夜12点来变换日期
而现在需要它根据八字日柱来变换日期
jd的变换可以仿照上例来改变 但是新月时间new_moons[index - 1]的日柱变换 在lunar_date[2]中表示不出来 经常出现 lunar_date[2]计算差错
比如new_moons[index - 1]的日柱变换 是在新月前一天的24点之前出现 这时根据日柱 0点之后的阴历日期 依然是初一 而计算为初二
问题就出在 无法表示出来new_moons[index - 1]的日柱 使得它随着当日的变换而变
现在需要 表示出new_moons[index - 1]的日柱数
然后与jd的日柱数抵减 来精确求得阴历日期
哪位高手 能够表示出来 先谢谢