//用offset减去每农历年的天数//计算当天是农历第几天//i最终结果是农历的年份//offset是当年的第几天 intiYear,daysOfYear=0; for(iYear=1900;iYear<10000&&offset>0;iYear++){ daysOfYear=yearDays(iYear); offset-=daysOfYear; monCyl+=12; } if(offset<0){ offset+=daysOfYear; iYear--; monCyl-=12; } //农历年份 year=iYear;setYear(year);//设置公历对应的农历年份 yearCyl=iYear-1864; leapMonth=leapMonth(iYear);//闰哪个月,1-12 leap=false; //用当年的天数offset,逐个减去每月(农历)的天数,求出当天是本月的第几天 intiMonth,daysOfMonth=0; for(iMonth=1;iMonth<13&&offset>0;iMonth++){ //闰月 if(leapMonth>0&&iMonth==(leapMonth+1)&&!leap){ --iMonth; leap=true; daysOfMonth=leapDays(year); }else daysOfMonth=monthDays(year,iMonth); offset-=daysOfMonth; //解除闰月 if(leap&&iMonth==(leapMonth+1)) leap=false; if(!leap) monCyl++; } //offset为0时,并且刚才计算的月份是闰月,要校正 if(offset==0&&leapMonth>0&&iMonth==leapMonth+1){ if(leap){