?? riqizhuanhuan.txt
字號:
days+=GetNongRunYueDays(year);
return days;
}
//獲取農(nóng)歷年閏月天數(shù)
int CCalendarConvert::GetNongRunYueDays(int year)
{
if(GetNongRunYue(year)==0)
return 0;
int days=RunYueIsLarge(year)?30:29;
return days;
}
//獲取農(nóng)歷閏月
int CCalendarConvert::GetNongRunYue(int year)
{
return (CalendarData[year-m_minyear][2] & 0x0f);
}
//公歷日期到元旦的天數(shù)
int CCalendarConvert::DaysFromNewYear(CALENDAR m_day)
{
int days=0;
for(int i=1;i<m_day.month;i++)
days+=GetGongMonthDays(m_day.year,i);
days+=m_day.day;
return days;
}
//農(nóng)歷日期到春節(jié)的天數(shù)
int CCalendarConvert::DaysFromSpringDay(CALENDAR m_day)
{
int days=0;
int month=GetNongRunYue(m_day.year);//處理閏月
if(month<m_day.month) //閏月小于日期月份
days+=GetNongRunYueDays(m_day.year);
else
{
if((month==m_day.month) && m_day.isrunyue)//日期月份是閏月
days+=GetNongRunYueDays(m_day.year);
}
for(int i=1;i<m_day.month;i++)
days+=GetNongMonthDays(m_day.year,i);
days+=m_day.day;
return days;
}
//公歷年是否閏年
BOOL CCalendarConvert::YearIsRunNian(int year)
{
return (CalendarData[year-m_minyear][0] & 0x80);
}
//判斷閏月是否為大月
BOOL CCalendarConvert::RunYueIsLarge(int year)
{
return (CalendarData[year-m_minyear][0]&0x40);
}
//計算2的N次方
int CCalendarConvert::Cal2N(int n)
{
int ret=1;
for(int i=0;i<n;i++)
ret*=2;
return ret;
}
//判斷農(nóng)歷年的月份是否為大月
BOOL CCalendarConvert::NongMonthIsLarge(int year,int month)
{
BOOL ret=FALSE;
if(month<9)
{
if(CalendarData[year-m_minyear][1] & Cal2N(8-month))
ret=TRUE;
}
else
{
unsigned char ch=Cal2N(12-month);
ch<<=4;
if(CalendarData[year-m_minyear][2] & ch)
ret=TRUE;
}
return ret;
}
//判斷公歷月份是否為大月(二月除外)
BOOL CCalendarConvert::GongMonthIsLarge(int month)
{
BOOL ret=FALSE;
if(month<8)
{
if(month%2)
ret=TRUE;
}
else
{
if(!(month%2))
ret=TRUE;
}
return ret;
}
//農(nóng)歷大年初一到元旦的天數(shù)
int CCalendarConvert::GetDaysFromStart(int year)
{
return (CalendarData[year-m_minyear][0]&0x3f);
}
/*********暫時沒有用到的成員函數(shù)***********/
//判斷是否是閏月
BOOL CCalendarConvert::MonthIsRunYue(int year,int month)
{
return (month==GetNongRunYue(year));
}
//獲取公歷兩個日期之間的天數(shù)
int CCalendarConvert::GetGongDays(CALENDAR m_start,CALENDAR m_end)
{
int days=0;
for(int i=m_start.year;i<m_end.year;i++)
days+=GetGongYearDays(i);
days-=DaysFromNewYear(m_start);
days+=DaysFromNewYear(m_end);
return days;
}
//獲取農(nóng)歷兩個日期之間的天數(shù)
int CCalendarConvert::GetNongDays(CALENDAR m_start,CALENDAR m_end)
{
int days=0;
for(int i=m_start.year;i<m_end.year;i++)
days+=GetNongYearDays(i);
days-=DaysFromSpringDay(m_start);
days+=DaysFromSpringDay(m_end);
return days;
}
//將當前公歷日期合成為結構
CALENDAR CCalendarConvert::GetCurGongDate()
{
CALENDAR m_cal;
SYSTEMTIME m_time;
GetLocalTime(&m_time);
m_cal.year=(int)m_time.wYear;
m_cal.month=(int)m_time.wMonth;
m_cal.day=(int)m_time.wDay;
m_cal.week=(int)m_time.wDayOfWeek;
return m_cal;
}
//比較兩個日期的大小
int CCalendarConvert::CompareTwoDate(CALENDAR m_fir,CALENDAR m_sec)
{
int m_state=0;
if(m_fir.year>m_sec.year)
m_state=1;
else
{
if(m_fir.year<m_sec.year)
m_state=-1;
else
{
if(m_fir.month>m_sec.month)
m_state=1;
else
{
if(m_fir.month<m_sec.month)
m_state=-1;
else
{
if(m_fir.day>m_sec.day)
m_state=1;
else
{
if(m_fir.day<m_sec.day)
m_state=-1;
else
m_state=0;
}
}
}
}
}
return m_state;
}
//獲取60年中的第N年的天干地支名稱
CString CCalendarConvert::GetNNameIn60(int index)
{
char ShengXiao[25]="鼠牛虎兔龍蛇馬羊猴雞狗豬";
char TianGan[21]="甲乙丙丁戊己庚辛壬癸";
char DiZhi[25]="子丑寅卯辰巳午未申酉戌亥";
char buffer[20];
memset(buffer,0,20);
strcpy(buffer,"農(nóng)歷");
int m_cur=0,m_this=0;
int tian=0,di=0;
for(int i=0;i<60;i++)
{
tian=i%10;
di=i%12;
if(m_this==index)
{
strncpy(&buffer[4],&TianGan[tian*2],2);
strncpy(&buffer[6],&DiZhi[di*2],2);
strcat(buffer,"年,");
strncpy(&buffer[12],&ShengXiao[di*2],2);
strcat(buffer,"年");
}
m_this++;
}
return CString(buffer);
}
//獲取農(nóng)歷年份的干支名稱
CString CCalendarConvert::GetGanZhi(int m_nongyear)
{
int m_index=(m_nongyear-1924)%60;
return GetNNameIn60(m_index);
}
//將農(nóng)歷年的月份注入組合框
void CCalendarConvert::NongMonthToList(int m_n
Top
3 樓guanmj(雪在燒)回復于 2003-01-06 16:32:23 得分 40#define firstyear 1936 /* the first year in lunarcal[] */
struct convdate
{
int source;
int solaryear;
int solarmonth;
int solardate;
int lunaryear;
int lunarmonth;
int lunardate;
int weekday;
int kan;
int chih;
};
struct taglunarcal
{
int basedays; /* 到西歷 1 月 1 日到農(nóng)歷正月初一的累積日數(shù) */
int intercalation; /* 閏月月份. 0==此年沒有閏月 */
int baseweekday; /* 此年西歷 1 月 1 日為星期幾再減 1 */
int basekanchih; /* 此年西歷 1 月 1 日之干支序號減 1 */
int monthdays[13]; /* 此農(nóng)歷年每月之大小, 0==小月(29日), 1==大月(30日)*/
};
struct taglunarcal lunarcal[] = {
{ 23, 3, 2, 17, 1, 0, 0, 1, 0, 0, 1, 1, 0, 1, 1, 1, 0 }, /* 1936 */
{ 41, 0, 4, 23, 1, 0, 0, 1, 0, 0, 1, 0, 1, 1, 1, 0, 1 },
{ 30, 7, 5, 28, 1, 1, 0, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1 },
{ 49, 0, 6, 33, 1, 1, 0, 0, 1, 0, 0, 1, 0, 1,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, 1, 0, 1, 1 },
{ 30, 8, 3, 47, 1, 1, 0, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1 }, /* 1976 */
{ 48, 0, 5, 53, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 0, 1 },
{ 37, 0, 6, 58, 1, 0, 1, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1 },
{ 27, 6, 0, 3, 1, 0, 0, 1, 0, 1, 1, 0, 1, 1, 0, 1, 0 },
{ 46, 0, 1, 8, 1, 0, 0, 1, 0, 1, 0, 1, 1, 0, 1, 1, 0 }, /* 1980 */
{ 35, 0, 3, 14, 0, 1, 0, 0, 1, 0, 0, 1, 1, 0, 1, 1, 1 },
{ 24, 4, 4, 19, 1, 0, 1, 0, 0, 1, 0, 0, 1, 0, 1, 1, 1 },
{ 43, 0, 5, 24, 1, 0, 1, 0, 0, 1, 0, 0, 1, 0, 1, 1, 1 },
{ 32, 10, 6, 29, 1, 0, 1, 1, 0, 0, 1, 0, 0, 1, 0, 1, 1 }, /* 1984 */
{ 50, 0, 1, 35, 0, 1, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0 },
{ 39, 0, 2, 40, 0, 1, 1, 0, 1, 1, 0, 1, 0, 1, 0, 0, 1 },
{ 28, 6, 3, 45, 1, 0, 1, 0, 1, 1, 0, 1, 1, 0, 1, 0, 0 },
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -