internal bool LunarToGregorian(int nLYear, int nLMonth, int nLDate, ref int nSolarYear, ref int nSolarMonth, ref int nSolarDay) {
int numLunarDays;
if (nLDate < 1 || nLDate > 30)
return false;
numLunarDays = nLDate-1;
//Add previous months days to form the total num of days from the first of the month.
for (int i = 1; i < nLMonth; i++) {
numLunarDays += InternalGetDaysInMonth(nLYear, i);
}
//Get Gregorian First of year
int nJan1Month = GetYearInfo(nLYear, Jan1Month);
int nJan1Date = GetYearInfo(nLYear, Jan1Date);
// calc the solar day of year of 1 Lunar day
int fLeap = GergIsleap(nLYear);
int[] days = (fLeap==1)? DaysToMonth366: DaysToMonth365;
nSolarDay = nJan1Date;
if (nJan1Month > 1)
nSolarDay += days [nJan1Month-1];
// Add the actual lunar day to get the solar day we want
nSolarDay = nSolarDay + numLunarDays;// - 1;
if ( nSolarDay > (fLeap + 365)) {
nSolarYear = nLYear + 1;
nSolarDay -= (fLeap + 365);
} else {
nSolarYear = nLYear;
}
for (nSolarMonth = 1; nSolarMonth < 12; nSolarMonth++) {
if (days[nSolarMonth] >= nSolarDay)
break;
}
nSolarDay -= days[nSolarMonth-1];
return true;
}