急需阴阳历转换算法,阳历转阴历就可以,谢谢 rt 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 //文件CalendarConvert.cpp#include "stdafx.h"#include "CalendarConvert.h"/*************** 本类调用规则 ************************************************************************1. 使用下面的函数来制作日历结构 MakeCalendar(CALENDAR *m_cal,int y,int m,int d);//填充日期结构的年月日2. 使用本函数来检验日历是否合法 BOOL GongDataIsValid(CALENDAR m_date); //判断公历日期是否在界内 BOOL NongDataIsValid(CALENDAR m_date); //判断农历日期是否在界内3. 将合法日历进行公农历相互转换 CALENDAR ConvertToGongLi(CALENDAR m_nongli); //将农历日期转化为公历日期 CALENDAR ConvertToNongLi(CALENDAR m_gongli); //将公历日期转化为农历日期4. 其他辅助函数:获取星期;获取公历日期之间天数;获取农历日期之间天数 int GetWeekInfo(CALENDAR m_gongli); //根据公历日期计算星期 int GetGongDays(CALENDAR m_start,CALENDAR m_end);//获取公历两个日期之间的天数 int GetNongDays(CALENDAR m_start,CALENDAR m_end);//获取农历两个日期之间的天数 int CompareTwoDate(CALENDAR m_fir,CALENDAR m_sec);//比较两个日期的大小 CALENDAR GetCurGongDate(); //将当前公历日期合成为结构 CString GetGanZhi(int m_nongyear); //获取农历年份的干支名称********************************************************************* 调用规则结束 ******************/CCalendarConvert::CCalendarConvert(){ m_minyear=1950; m_maxyear=2050; unsigned char data[100][3]= { {0x2f,0x6c,0xa0},{0x24,0xb5,0x50},{0xda,0x53,0x55},{0x2c,0x4d,0xa0}, {0x21,0xa5,0xb0},{0x57,0x45,0x73},{0xaa,0x52,0xb0},{0x1e,0xa9,0xa8}, {0x30,0xe9,0x50},{0x26,0x6a,0xa0},{0x9b,0xae,0xa6},{0x2d,0xab,0x50}, {0x23,0x4b,0x60},{0x18,0xaa,0xe4},{0xab,0xa5,0x70},{0x20,0x52,0x60}, {0x14,0xf2,0x63},{0x27,0xd9,0x50},{0x9d,0x5b,0x57},{0x2f,0x56,0xa0}, {0x24,0x96,0xd0},{0x1a,0x4d,0xd5},{0xad,0x4a,0xd0},{0x21,0xa4,0xd0}, {0x16,0xd4,0xd4},{0x29,0xd2,0x50},{0x9e,0xd5,0x58},{0x30,0xb5,0x40}, {0x25,0xb6,0xa0},{0x5b,0x95,0xa6},{0xae,0x95,0xb0},{0x23,0x49,0xb0}, {0x18,0xa9,0x74},{0x2b,0xa4,0xb0},{0xa0,0xb2,0x7a},{0x32,0x6a,0x50}, {0x27,0x6d,0x40},{0x1c,0xaf,0x46},{0xaf,0xab,0x60},{0x24,0x95,0x70}, {0x1a,0x4a,0xf5},{0x2d,0x49,0x70},{0xa2,0x64,0xb0},{0x16,0x74,0xa3}, {0x28,0xea,0x50},{0x1e,0x6b,0x58},{0xb1,0x5a,0xc0},{0x25,0xab,0x60}, {0x1b,0x96,0xd5},{0x2e,0x92,0xe0},{0xa3,0xc9,0x60},{0x17,0xd9,0x54}, {0x2a,0xd4,0xa0},{0x1f,0xda,0x50},{0x95,0x75,0x52},{0x27,0x56,0xa0}, {0x1c,0xab,0xb7},{0x30,0x25,0xd0},{0xa5,0x92,0xd0},{0x19,0xca,0xb5}, {0x2c,0xa9,0x50},{0x21,0xb4,0xa0},{0x96,0xba,0xa4},{0x28,0xad,0x50}, {0x1e,0x55,0xd9},{0x31,0x4b,0xa0},{0xa6,0xa5,0xb0},{0x5b,0x51,0x76}, {0x2e,0x52,0xb0},{0x23,0xa9,0x30},{0x98,0x79,0x54},{0x2a,0x6a,0xa0}, {0x1f,0xad,0x50},{0x15,0x5b,0x52},{0xa8,0x4b,0x60},{0x1c,0xa6,0xe6}, {0x2f,0xa4,0xe0},{0x24,0xd2,0x60},{0x99,0xea,0x65},{0x2b,0xd5,0x30}, {0x21,0x5a,0xa0},{0x16,0x76,0xa3},{0xa9,0x96,0xd0},{0x1e,0x4a,0xfb}, {0x31,0x4a,0xd0},{0x26,0xa4,0xd0},{0xdb,0xd0,0xb6},{0x2d,0xd2,0x50}, {0x22,0xd5,0x20},{0x17,0xdd,0x45},{0xaa,0xb5,0xa0},{0x1f,0x56,0xd0}, {0x15,0x55,0xb2},{0x28,0x49,0xb0},{0x9d,0xa5,0x77},{0x2f,0xa4,0xb0}, {0x24,0xaa,0x50},{0x59,0xb2,0x55},{0xac,0x6d,0x20},{0x20,0xad,0xa0} }; CalendarData=new char*[100]; for(int i=0;i<100;i++) { CalendarData[i]=new char[3]; for(int j=0;j<3;j++) CalendarData[i][j]=data[i][j]; }}CCalendarConvert::~CCalendarConvert(){ for(int i=0;i<100;i++) delete[] CalendarData[i]; delete[] CalendarData;}//判断公历日期是否在界内BOOL CCalendarConvert::GongDataIsValid(CALENDAR m_date){ if(m_date.year>1950 && m_date.year<2050) return TRUE; else { if(m_date.year==1950) { if(m_date.month>2) return TRUE; else { if(m_date.month==2) { if(m_date.day>16) return TRUE; } } } } return FALSE;}//判断农历日期是否在界内BOOL CCalendarConvert::NongDataIsValid(CALENDAR m_date){ if(m_date.year>1949 && m_date.year<2049) return TRUE; else { if(m_date.year==2049) { if(m_date.month<12) return TRUE; else { if(m_date.month==12) { if(m_date.day<8) return TRUE; } } } } return FALSE;}//将农历日期转化为公历日期CALENDAR CCalendarConvert::ConvertToGongLi(CALENDAR m_nongli){ int days=DaysFromSpringDay(m_nongli); //计算农历当前日期到春节的天数 days+=GetDaysFromStart(m_nongli.year);//加上春节到元旦的天数(以元旦为基准) int year=m_nongli.year; //默认年份相同 int alldays=GetGongYearDays(m_nongli.year);//计算农历年的公历天数 if(days>alldays) //公历年份超前 { days-=alldays; year++; } CALENDAR result=CalGongDate(year,days);//根据以元旦为基准的天数来确定日期 result.week=GetWeekInfo(result); return result;} //将公历日期转化为农历日期CALENDAR CCalendarConvert::ConvertToNongLi(CALENDAR m_gongli){ int days=DaysFromNewYear(m_gongli); //公历日期到元旦的天数 int alldays=GetDaysFromStart(m_gongli.year);//春节到元旦的天数 int year=m_gongli.year; //默认农历年与公历年相同 if(days<=alldays) //农历年滞后 { year--; days+=GetGongYearDays(year); //再加上公历年的整年天数 } days-=GetDaysFromStart(year); //减去春节到元旦天数得到以春节为基准的天数 CALENDAR result=CalNongDate(year,days);//根据农历年和以春节为基准的天数计算公历日期 result.week=GetWeekInfo(m_gongli); return result;}//根据公历日期计算星期int CCalendarConvert::GetWeekInfo(CALENDAR m_gongli){ int left=0; for(int i=m_minyear;i<m_gongli.year;i++)//1950年元旦为星期六 { left+=YearIsRunNian(i)?2:1; left%=7; } for(i=1;i<m_gongli.month;i++) { left+=GetGongMonthDays(m_gongli.year,i); left%=7; } left+=(m_gongli.day+6); left%=7; return left;}//当前公历日期后N天的公历日期CALENDAR CCalendarConvert::GetDateAfterDays(CALENDAR m_first,int m_days){ int m_firstdays=DaysFromNewYear(m_first)+m_days; return CalGongDate(m_first.year,m_firstdays);}//根据给定年份并且以元旦为基准的天数来确定公历日期CALENDAR CCalendarConvert::CalGongDate(int year,int days){ CALENDAR result; int caldays=0; result.year=year; for(int i=1;i<13;i++) { caldays+=GetGongMonthDays(year,i); if(caldays>=days) { caldays-=GetGongMonthDays(year,i); result.month=i; result.day=days-caldays; break; } } return result;}//根据农历年和以春节为基准的天数计算公历日期CALENDAR CCalendarConvert::CalNongDate(int year,int days){ CALENDAR result; int caldays=0; result.year=year; result.isrunyue=FALSE; for(int i=1;i<13;i++) { caldays+=GetNongMonthDays(year,i); //计算春节以来月天数累加和 if(caldays>=days) //天数超过总天数,月份已到 { caldays-=GetNongMonthDays(year,i); //减去多算的一个月 result.month=i; result.day=days-caldays; result.isrunyue=FALSE; break; } else { if(GetNongRunYue(year)==i) //考虑闰月 { caldays+=GetNongRunYueDays(year); if(caldays>=days) { caldays-=GetNongRunYueDays(year); result.month=i; result.day=days-caldays; result.isrunyue=TRUE; break; } } } } return result;}//填充日期结构的年月日void CCalendarConvert::MakeCalendar(CALENDAR *m_cal,int y,int m,int d){ m_cal->year=y; m_cal->month=m; m_cal->day=d;}//获取公历月的天数int CCalendarConvert::GetGongMonthDays(int year,int month){ int ret=30; if(month==2) ret=YearIsRunNian(year)?29:28; else ret=GongMonthIsLarge(month)?31:30; return ret;}//获取农历月的天数int CCalendarConvert::GetNongMonthDays(int year,int month){ int days=NongMonthIsLarge(year,month)?30:29; return days;}//获取农历月的天数int CCalendarConvert::GetNongMonthDays(int year,int month,BOOL m_run){ int days=0; if(m_run) days=GetNongRunYueDays(year); else days=GetNongMonthDays(year,month); return days;}//获取公历年的天数int CCalendarConvert::GetGongYearDays(int year){ int days=YearIsRunNian(year)?366:365; return days;}//获取农历年的天数int CCalendarConvert::GetNongYearDays(int year){ int days=0; for(int i=1;i<13;i++) days+=GetNongMonthDays(year,i); days+=GetNongRunYueDays(year); return days;}//获取农历年闰月天数int CCalendarConvert::GetNongRunYueDays(int year){ if(GetNongRunYue(year)==0) return 0; int days=RunYueIsLarge(year)?30:29; return days;}//获取农历闰月int CCalendarConvert::GetNongRunYue(int year){ return (CalendarData[year-m_minyear][2] & 0x0f);}//公历日期到元旦的天数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;}//农历日期到春节的天数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;}//判断农历年的月份是否为大月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;}//农历大年初一到元旦的天数int CCalendarConvert::GetDaysFromStart(int year){ return (CalendarData[year-m_minyear][0]&0x3f);}/*********暂时没有用到的成员函数***********///判断是否是闰月BOOL CCalendarConvert::MonthIsRunYue(int year,int month){ return (month==GetNongRunYue(year));}//获取公历两个日期之间的天数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;}//获取农历两个日期之间的天数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,"农历"); 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);}//获取农历年份的干支名称CString CCalendarConvert::GetGanZhi(int m_nongyear){ int m_index=(m_nongyear-1924)%60; return GetNNameIn60(m_index);}//将农历年的月份注入组合框void CCalendarConvert::NongMonthToList(int m_n #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 日到农历正月初一的累积日数 */ int intercalation; /* 闰月月份. 0==此年没有闰月 */ int baseweekday; /* 此年西历 1 月 1 日为星期几再减 1 */ int basekanchih; /* 此年西历 1 月 1 日之干支序号减 1 */ int monthdays[13]; /* 此农历年每月之大小, 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, 0, 1, 1 },{ 38, 0, 0, 38, 1, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1 }, /* 1940 */{ 26, 6, 2, 44, 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西历年每月之日数 */int solarcal[12] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };/ * 西历年每月之累积日数, 平年与闰年 */int solardays[2][14] = {{ 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365, 396 },{ 0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335, 366, 397 } };/* 求此西历年是否为闰年, 返回 0 为平年, 1 为闰年 */int getleap( int year ){ if ( year % 400 == 0 ) return 1; else if ( year % 100 == 0 ) return 0; else if ( year % 4 == 0 ) return 1; else return 0;}/* 西历农历转换 */int calconv( struct convdate *cd ){ int leap, d, sm, y, im, l1, l2, acc, i, lm, kc; if ( cd->source == 0 ) /* solar */ { if ( cd->solaryear <= firstyear || cd->solaryear > lastyear ) return 1; sm = cd->solarmonth - 1; if ( sm < 0 || sm > 11 ) return 2; leap = getleap( cd->solaryear ); if ( sm == 1 ) d = leap + 28; else d = solarcal[sm]; if ( cd->solardate < 1 || cd->solardate > d ) return 3; y = cd->solaryear - firstyear; acc = solardays[leap][sm] + cd->solardate; cd->weekday = ( acc + lunarcal[y].baseweekday ) % 7; kc = acc + lunarcal[y].basekanchih; cd->kan = kc % 10; cd->chih = kc % 12; if ( acc <= lunarcal[y].basedays ) { y--; cd->lunaryear = cd->solaryear - 1; leap = getleap( cd->lunaryear ); sm += 12; acc = solardays[leap][sm] + cd->solardate; } else cd->lunaryear = cd->solaryear; l1 = lunarcal[y].basedays; for ( i=0; i<13; i++ ) { l2 = l1 + lunarcal[y].monthdays[i] + 29; if ( acc <= l2 ) break; l1 = l2; } cd->lunarmonth = i + 1; cd->lunardate = acc - l1; im = lunarcal[y].intercalation; if ( im != 0 && cd->lunarmonth > im ) { cd->lunarmonth--; if ( cd->lunarmonth == im ) cd->lunarmonth = -im; } if ( cd->lunarmonth > 12 ) cd->lunarmonth -= 12; } else /* lunar */ { if ( cd->lunaryear < firstyear || cd->lunaryear >= lastyear ) return 1; y = cd->lunaryear - firstyear; im = lunarcal[y].intercalation; lm = cd->lunarmonth; if ( lm < 0 ) { if ( lm != -im ) return 2; } else if ( lm < 1 || lm > 12 ) return 2; if ( im != 0 ) { if ( lm > im ) lm++; else if ( lm == -im ) lm = im + 1; } lm--; if ( cd->lunardate > lunarcal[y].monthdays[lm] + 29 ) return 3; acc = lunarcal[y].basedays; for ( i=0; i acc += lunarcal[y].monthdays[i] + 29; acc += cd->lunardate; leap = getleap( cd->lunaryear ); for ( i=13; i>=0; i-- ) if ( acc > solardays[leap][i] ) break; cd->solardate = acc - solardays[leap][i]; if ( i <= 11 ) { cd->solaryear = cd->lunaryear; cd->solarmonth = i + 1; } else { cd->solaryear = cd->lunaryear + 1; cd->solarmonth = i - 11; } leap = getleap( cd->solaryear ); y = cd->solaryear - firstyear; acc = solardays[leap][cd->solarmonth-1] + cd->solardate; cd->weekday = ( acc + lunarcal[y].baseweekday ) % 7; kc = acc + lunarcal[y].basekanchih; cd->kan = kc % 10; cd->chih = kc % 12; }return 0;} //文件CalendarConvert.h#ifndef __CALENDARCONVERT__H_#define __CALENDARCONVERT__H_typedef struct CalendarStruct{ CalendarStruct(){} CalendarStruct(int m_y,int m_m,int m_d) { FillThis(m_y,m_m,m_d); } int year; int month; int day; int week; BOOL isrunyue; void FillThis(int m_y,int m_m,int m_d) { year=m_y; month=m_m; day=m_d; } void FromFile(CFile &m_file) { m_file.Read((char *)&year,sizeof(int)); m_file.Read((char *)&month,sizeof(int)); m_file.Read((char *)&day,sizeof(int)); } void ToFile(CFile &m_file) { m_file.Write((char *)&year,sizeof(int)); m_file.Write((char *)&month,sizeof(int)); m_file.Write((char *)&day,sizeof(int)); }}CALENDAR;class CCalendarConvert{public: CCalendarConvert(); ~CCalendarConvert();public: CALENDAR ConvertToGongLi(CALENDAR m_nongli); //将农历日期转化为公历日期 CALENDAR ConvertToNongLi(CALENDAR m_gongli); //将公历日期转化为农历日期 int GetWeekInfo(CALENDAR m_gongli); //根据公历日期计算星期 void MakeCalendar(CALENDAR *m_cal,int y,int m,int d);//填充日期结构的年月日 BOOL GongDataIsValid(CALENDAR m_date); //判断公历日期是否在界内 BOOL NongDataIsValid(CALENDAR m_date); //判断农历日期是否在界内 int GetGongDays(CALENDAR m_start,CALENDAR m_end); //获取公历两个日期之间的天数 int GetNongDays(CALENDAR m_start,CALENDAR m_end); //获取农历两个日期之间的天数 int DaysFromNewYear(CALENDAR m_day); //公历日期到元旦的天数 CALENDAR CalGongDate(int year,int days); //根据天数(到元旦)计算公历日期 int CompareTwoDate(CALENDAR m_fir,CALENDAR m_sec); //比较两个日期的大小 CALENDAR GetCurGongDate(); //将当前公历日期合成为结构 CALENDAR GetDateAfterDays(CALENDAR m_first,int m_days);//当前公历日期后N天的公历日期 int GetNongRunYue(int year); //获取农历闰月 CString GetGanZhi(int m_nongyear); //获取农历年份的干支名称 void NongMonthToList(int m_nongyear,CComboBox & m_list);//将农历年的月份注入组合框 int GetGongMonthDays(int year,int month); //获取公历月的天数 int GetNongMonthDays(int year,int month); //获取农历月的天数 int GetNongMonthDays(int year,int month,BOOL m_run);//获取农历月的天数 int GetNongRunYueDays(int year); //获取农历年闰月天数protected: int GetGongYearDays(int year); //获取公历年的天数 int GetNongYearDays(int year); //获取农历年的天数 int DaysFromSpringDay(CALENDAR m_day); //农历日期到春节的天数 CALENDAR CalNongDate(int year,int days); //价格天数(到春节)计算农历日期 BOOL YearIsRunNian(int year); //公历年是否闰年 BOOL RunYueIsLarge(int year); //判断闰月是否为大月 BOOL MonthIsRunYue(int year,int month); //判断是否是闰月 BOOL NongMonthIsLarge(int year,int month); //判断农历年的月份是否为大月 BOOL GongMonthIsLarge(int month); //判断公历月份是否为大月(二月除外) int GetDaysFromStart(int year); //农历大年初一到元旦的天数 int Cal2N(int n); //计算2的N次方 CString GetNNameIn60(int index); //获取60年中的第N年的天干地支名称private: int m_maxyear; //支持的最大年份 int m_minyear; //支持的最小年份 char **CalendarData; //公农历转化数据};#endif 才毕业,不知道技术发展方向,有同感和有经验的同志讨论讨论! VC在对话框上添加按钮双击无法添加响应事件 ATL的activex如何写inf生成cab? 配置文件如何写》?》 在vc下怎樣使用諸如swap等這樣的標准c++函數 我的.NET和VC是中文的,Visual Assist 不能用?那儿有 .NET和VC 改变为英文的系统文件? 关于模板的奇怪问题,c++/VC高手请进 托盘编程问题。 关于ado访问多表的一个问题(非常着急)(速答,速给分,绝不食言)!!!!!!!!!!! 列表框数据删除问题 学习中遇到一个小问题。来者有分 看看这个人:zxhong (红) 他是什么?
#include "CalendarConvert.h"
/*************** 本类调用规则 ******************
******************************************************1. 使用下面的函数来制作日历结构
MakeCalendar(CALENDAR *m_cal,int y,int m,int d);//填充日期结构的年月日2. 使用本函数来检验日历是否合法
BOOL GongDataIsValid(CALENDAR m_date); //判断公历日期是否在界内
BOOL NongDataIsValid(CALENDAR m_date); //判断农历日期是否在界内3. 将合法日历进行公农历相互转换
CALENDAR ConvertToGongLi(CALENDAR m_nongli); //将农历日期转化为公历日期
CALENDAR ConvertToNongLi(CALENDAR m_gongli); //将公历日期转化为农历日期4. 其他辅助函数:获取星期;获取公历日期之间天数;获取农历日期之间天数
int GetWeekInfo(CALENDAR m_gongli); //根据公历日期计算星期
int GetGongDays(CALENDAR m_start,CALENDAR m_end);//获取公历两个日期之间的天数
int GetNongDays(CALENDAR m_start,CALENDAR m_end);//获取农历两个日期之间的天数
int CompareTwoDate(CALENDAR m_fir,CALENDAR m_sec);//比较两个日期的大小
CALENDAR GetCurGongDate(); //将当前公历日期合成为结构
CString GetGanZhi(int m_nongyear); //获取农历年份的干支名称******************************************************
*************** 调用规则结束 ******************/CCalendarConvert::CCalendarConvert()
{
m_minyear=1950;
m_maxyear=2050; unsigned char data[100][3]=
{
{0x2f,0x6c,0xa0},{0x24,0xb5,0x50},{0xda,0x53,0x55},{0x2c,0x4d,0xa0},
{0x21,0xa5,0xb0},{0x57,0x45,0x73},{0xaa,0x52,0xb0},{0x1e,0xa9,0xa8},
{0x30,0xe9,0x50},{0x26,0x6a,0xa0},{0x9b,0xae,0xa6},{0x2d,0xab,0x50},
{0x23,0x4b,0x60},{0x18,0xaa,0xe4},{0xab,0xa5,0x70},{0x20,0x52,0x60},
{0x14,0xf2,0x63},{0x27,0xd9,0x50},{0x9d,0x5b,0x57},{0x2f,0x56,0xa0}, {0x24,0x96,0xd0},{0x1a,0x4d,0xd5},{0xad,0x4a,0xd0},{0x21,0xa4,0xd0},
{0x16,0xd4,0xd4},{0x29,0xd2,0x50},{0x9e,0xd5,0x58},{0x30,0xb5,0x40},
{0x25,0xb6,0xa0},{0x5b,0x95,0xa6},{0xae,0x95,0xb0},{0x23,0x49,0xb0},
{0x18,0xa9,0x74},{0x2b,0xa4,0xb0},{0xa0,0xb2,0x7a},{0x32,0x6a,0x50},
{0x27,0x6d,0x40},{0x1c,0xaf,0x46},{0xaf,0xab,0x60},{0x24,0x95,0x70}, {0x1a,0x4a,0xf5},{0x2d,0x49,0x70},{0xa2,0x64,0xb0},{0x16,0x74,0xa3},
{0x28,0xea,0x50},{0x1e,0x6b,0x58},{0xb1,0x5a,0xc0},{0x25,0xab,0x60},
{0x1b,0x96,0xd5},{0x2e,0x92,0xe0},{0xa3,0xc9,0x60},{0x17,0xd9,0x54},
{0x2a,0xd4,0xa0},{0x1f,0xda,0x50},{0x95,0x75,0x52},{0x27,0x56,0xa0},
{0x1c,0xab,0xb7},{0x30,0x25,0xd0},{0xa5,0x92,0xd0},{0x19,0xca,0xb5}, {0x2c,0xa9,0x50},{0x21,0xb4,0xa0},{0x96,0xba,0xa4},{0x28,0xad,0x50},
{0x1e,0x55,0xd9},{0x31,0x4b,0xa0},{0xa6,0xa5,0xb0},{0x5b,0x51,0x76},
{0x2e,0x52,0xb0},{0x23,0xa9,0x30},{0x98,0x79,0x54},{0x2a,0x6a,0xa0},
{0x1f,0xad,0x50},{0x15,0x5b,0x52},{0xa8,0x4b,0x60},{0x1c,0xa6,0xe6},
{0x2f,0xa4,0xe0},{0x24,0xd2,0x60},{0x99,0xea,0x65},{0x2b,0xd5,0x30}, {0x21,0x5a,0xa0},{0x16,0x76,0xa3},{0xa9,0x96,0xd0},{0x1e,0x4a,0xfb},
{0x31,0x4a,0xd0},{0x26,0xa4,0xd0},{0xdb,0xd0,0xb6},{0x2d,0xd2,0x50},
{0x22,0xd5,0x20},{0x17,0xdd,0x45},{0xaa,0xb5,0xa0},{0x1f,0x56,0xd0},
{0x15,0x55,0xb2},{0x28,0x49,0xb0},{0x9d,0xa5,0x77},{0x2f,0xa4,0xb0},
{0x24,0xaa,0x50},{0x59,0xb2,0x55},{0xac,0x6d,0x20},{0x20,0xad,0xa0}
};
CalendarData=new char*[100];
for(int i=0;i<100;i++)
{
CalendarData[i]=new char[3];
for(int j=0;j<3;j++)
CalendarData[i][j]=data[i][j];
}
}
CCalendarConvert::~CCalendarConvert()
{
for(int i=0;i<100;i++)
delete[] CalendarData[i];
delete[] CalendarData;
}//判断公历日期是否在界内
BOOL CCalendarConvert::GongDataIsValid(CALENDAR m_date)
{
if(m_date.year>1950 && m_date.year<2050)
return TRUE;
else
{
if(m_date.year==1950)
{
if(m_date.month>2)
return TRUE;
else
{
if(m_date.month==2)
{
if(m_date.day>16)
return TRUE;
}
}
}
}
return FALSE;
}//判断农历日期是否在界内
BOOL CCalendarConvert::NongDataIsValid(CALENDAR m_date)
{
if(m_date.year>1949 && m_date.year<2049)
return TRUE;
else
{
if(m_date.year==2049)
{
if(m_date.month<12)
return TRUE;
else
{
if(m_date.month==12)
{
if(m_date.day<8)
return TRUE;
}
}
}
}
return FALSE;
}//将农历日期转化为公历日期
CALENDAR CCalendarConvert::ConvertToGongLi(CALENDAR m_nongli)
{
int days=DaysFromSpringDay(m_nongli); //计算农历当前日期到春节的天数
days+=GetDaysFromStart(m_nongli.year);//加上春节到元旦的天数(以元旦为基准)
int year=m_nongli.year; //默认年份相同
int alldays=GetGongYearDays(m_nongli.year);//计算农历年的公历天数
if(days>alldays) //公历年份超前
{
days-=alldays;
year++;
}
CALENDAR result=CalGongDate(year,days);//根据以元旦为基准的天数来确定日期
result.week=GetWeekInfo(result);
return result;
}
CALENDAR CCalendarConvert::ConvertToNongLi(CALENDAR m_gongli)
{
int days=DaysFromNewYear(m_gongli); //公历日期到元旦的天数
int alldays=GetDaysFromStart(m_gongli.year);//春节到元旦的天数 int year=m_gongli.year; //默认农历年与公历年相同
if(days<=alldays) //农历年滞后
{
year--;
days+=GetGongYearDays(year); //再加上公历年的整年天数
}
days-=GetDaysFromStart(year); //减去春节到元旦天数得到以春节为基准的天数
CALENDAR result=CalNongDate(year,days);//根据农历年和以春节为基准的天数计算公历日期
result.week=GetWeekInfo(m_gongli);
return result;
}//根据公历日期计算星期
int CCalendarConvert::GetWeekInfo(CALENDAR m_gongli)
{
int left=0;
for(int i=m_minyear;i<m_gongli.year;i++)//1950年元旦为星期六
{
left+=YearIsRunNian(i)?2:1;
left%=7;
}
for(i=1;i<m_gongli.month;i++)
{
left+=GetGongMonthDays(m_gongli.year,i);
left%=7;
}
left+=(m_gongli.day+6);
left%=7;
return left;
}//当前公历日期后N天的公历日期
CALENDAR CCalendarConvert::GetDateAfterDays(CALENDAR m_first,int m_days)
{
int m_firstdays=DaysFromNewYear(m_first)+m_days;
return CalGongDate(m_first.year,m_firstdays);
}//根据给定年份并且以元旦为基准的天数来确定公历日期
CALENDAR CCalendarConvert::CalGongDate(int year,int days)
{
CALENDAR result;
int caldays=0;
result.year=year; for(int i=1;i<13;i++)
{
caldays+=GetGongMonthDays(year,i);
if(caldays>=days)
{
caldays-=GetGongMonthDays(year,i);
result.month=i;
result.day=days-caldays;
break;
}
}
return result;
}//根据农历年和以春节为基准的天数计算公历日期
CALENDAR CCalendarConvert::CalNongDate(int year,int days)
{
CALENDAR result;
int caldays=0;
result.year=year;
result.isrunyue=FALSE; for(int i=1;i<13;i++)
{
caldays+=GetNongMonthDays(year,i); //计算春节以来月天数累加和
if(caldays>=days) //天数超过总天数,月份已到
{
caldays-=GetNongMonthDays(year,i); //减去多算的一个月
result.month=i;
result.day=days-caldays;
result.isrunyue=FALSE;
break;
}
else
{
if(GetNongRunYue(year)==i) //考虑闰月
{
caldays+=GetNongRunYueDays(year);
if(caldays>=days)
{
caldays-=GetNongRunYueDays(year);
result.month=i;
result.day=days-caldays;
result.isrunyue=TRUE;
break;
}
}
}
}
return result;
}//填充日期结构的年月日
void CCalendarConvert::MakeCalendar(CALENDAR *m_cal,int y,int m,int d)
{
m_cal->year=y;
m_cal->month=m;
m_cal->day=d;
}//获取公历月的天数
int CCalendarConvert::GetGongMonthDays(int year,int month)
{
int ret=30;
if(month==2)
ret=YearIsRunNian(year)?29:28;
else
ret=GongMonthIsLarge(month)?31:30;
return ret;
}//获取农历月的天数
int CCalendarConvert::GetNongMonthDays(int year,int month)
{
int days=NongMonthIsLarge(year,month)?30:29;
return days;
}//获取农历月的天数
int CCalendarConvert::GetNongMonthDays(int year,int month,BOOL m_run)
{
int days=0;
if(m_run)
days=GetNongRunYueDays(year);
else
days=GetNongMonthDays(year,month);
return days;
}//获取公历年的天数
int CCalendarConvert::GetGongYearDays(int year)
{
int days=YearIsRunNian(year)?366:365;
return days;
}//获取农历年的天数
int CCalendarConvert::GetNongYearDays(int year)
{
int days=0;
for(int i=1;i<13;i++)
days+=GetNongMonthDays(year,i);
days+=GetNongRunYueDays(year);
return days;
}//获取农历年闰月天数
int CCalendarConvert::GetNongRunYueDays(int year)
{
if(GetNongRunYue(year)==0)
return 0;
int days=RunYueIsLarge(year)?30:29;
return days;
}//获取农历闰月
int CCalendarConvert::GetNongRunYue(int year)
{
return (CalendarData[year-m_minyear][2] & 0x0f);
}//公历日期到元旦的天数
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;
}//农历日期到春节的天数
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;
}//判断农历年的月份是否为大月
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;
}//农历大年初一到元旦的天数
int CCalendarConvert::GetDaysFromStart(int year)
{
return (CalendarData[year-m_minyear][0]&0x3f);
}
/*********暂时没有用到的成员函数***********/
//判断是否是闰月
BOOL CCalendarConvert::MonthIsRunYue(int year,int month)
{
return (month==GetNongRunYue(year));
}//获取公历两个日期之间的天数
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;
}//获取农历两个日期之间的天数
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,"农历");
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);
}
//获取农历年份的干支名称
CString CCalendarConvert::GetGanZhi(int m_nongyear)
{
int m_index=(m_nongyear-1924)%60;
return GetNNameIn60(m_index);
}//将农历年的月份注入组合框
void CCalendarConvert::NongMonthToList(int m_n
{
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 日到农历正月初一的累积日数 */
int intercalation; /* 闰月月份. 0==此年没有闰月 */
int baseweekday; /* 此年西历 1 月 1 日为星期几再减 1 */
int basekanchih; /* 此年西历 1 月 1 日之干支序号减 1 */
int monthdays[13]; /* 此农历年每月之大小, 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, 0, 1, 1 },
{ 38, 0, 0, 38, 1, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1 }, /* 1940 */
{ 26, 6, 2, 44, 1, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 0 },
{ 45, 0, 3, 49, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0 },
{ 35, 0, 4, 54, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1 },
{ 24, 4, 5, 59, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 1 }, /* 1944 */
{ 43, 0, 0, 5, 0, 0, 1, 0, 0, 1, 0, 1, 1, 1, 0, 1, 1 },
{ 32, 0, 1, 10, 1, 0, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 1 },
{ 21, 2, 2, 15, 1, 1, 0, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1 },
{ 40, 0, 3, 20, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1 }, /* 1948 */
{ 28, 7, 5, 26, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1 },
{ 47, 0, 6, 31, 0, 1, 1, 0, 1, 1, 0, 0, 1, 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, 1, 0, 1, 0, 1, 0 },
{ 21, 2, 6, 54, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1 },
{ 40, 0, 0, 59, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 1, 0, 1 }, /* 2024 */
{ 28, 6, 2, 5, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0 },
{ 47, 0, 3, 10, 1, 0, 1, 0, 0, 1, 0, 0, 1, 1, 1, 0, 1 },
{ 36, 0, 4, 15, 1, 1, 0, 1, 0, 0, 1, 0, 0, 1, 1, 0, 1 },
{ 25, 5, 5, 20, 1, 1, 1, 0, 1, 0, 0, 1, 0, 0, 1, 1, 0 }, /* 2028 */
{ 43, 0, 0, 26, 1, 1, 0, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1 },
{ 32, 0, 1, 31, 1, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 0 },
{ 22, 3, 2, 36, 0, 1, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 0 } };#define lastyear (firstyear+sizeof(lunarcal)/sizeof(struct taglunarcal)-1)/* 西历年每月之日数 */
int solarcal[12] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };/
int solardays[2][14] = {
{ 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365, 396 },
{ 0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335, 366, 397 } };/* 求此西历年是否为闰年, 返回 0 为平年, 1 为闰年 */
int getleap( int year )
{
if ( year % 400 == 0 )
return 1;
else if ( year % 100 == 0 )
return 0;
else if ( year % 4 == 0 )
return 1;
else
return 0;
}/* 西历农历转换 */
int calconv( struct convdate *cd )
{
int leap, d, sm, y, im, l1, l2, acc, i, lm, kc;
if ( cd->source == 0 ) /* solar */
{
if ( cd->solaryear <= firstyear || cd->solaryear > lastyear )
return 1;
sm = cd->solarmonth - 1;
if ( sm < 0 || sm > 11 )
return 2;
leap = getleap( cd->solaryear );
if ( sm == 1 )
d = leap + 28;
else
d = solarcal[sm];
if ( cd->solardate < 1 || cd->solardate > d )
return 3;
y = cd->solaryear - firstyear;
acc = solardays[leap][sm] + cd->solardate;
cd->weekday = ( acc + lunarcal[y].baseweekday ) % 7;
kc = acc + lunarcal[y].basekanchih;
cd->kan = kc % 10;
cd->chih = kc % 12;
if ( acc <= lunarcal[y].basedays )
{
y--;
cd->lunaryear = cd->solaryear - 1;
leap = getleap( cd->lunaryear );
sm += 12;
acc = solardays[leap][sm] + cd->solardate;
}
else
cd->lunaryear = cd->solaryear;
l1 = lunarcal[y].basedays;
for ( i=0; i<13; i++ )
{
l2 = l1 + lunarcal[y].monthdays[i] + 29;
if ( acc <= l2 )
break;
l1 = l2;
}
cd->lunarmonth = i + 1;
cd->lunardate = acc - l1;
im = lunarcal[y].intercalation;
if ( im != 0 && cd->lunarmonth > im )
{
cd->lunarmonth--;
if ( cd->lunarmonth == im )
cd->lunarmonth = -im;
}
if ( cd->lunarmonth > 12 )
cd->lunarmonth -= 12;
}
else /* lunar */
{
if ( cd->lunaryear < firstyear || cd->lunaryear >= lastyear )
return 1;
y = cd->lunaryear - firstyear;
im = lunarcal[y].intercalation;
lm = cd->lunarmonth;
if ( lm < 0 )
{
if ( lm != -im )
return 2;
}
else if ( lm < 1 || lm > 12 )
return 2;
if ( im != 0 )
{
if ( lm > im )
lm++;
else if ( lm == -im )
lm = im + 1;
}
lm--;
if ( cd->lunardate > lunarcal[y].monthdays[lm] + 29 )
return 3;
acc = lunarcal[y].basedays;
for ( i=0; i acc += lunarcal[y].monthdays[i] + 29;
acc += cd->lunardate;
leap = getleap( cd->lunaryear );
for ( i=13; i>=0; i-- )
if ( acc > solardays[leap][i] )
break;
cd->solardate = acc - solardays[leap][i];
if ( i <= 11 )
{
cd->solaryear = cd->lunaryear;
cd->solarmonth = i + 1;
}
else
{
cd->solaryear = cd->lunaryear + 1;
cd->solarmonth = i - 11;
}
leap = getleap( cd->solaryear );
y = cd->solaryear - firstyear;
acc = solardays[leap][cd->solarmonth-1] + cd->solardate;
cd->weekday = ( acc + lunarcal[y].baseweekday ) % 7;
kc = acc + lunarcal[y].basekanchih;
cd->kan = kc % 10;
cd->chih = kc % 12;
}
return 0;
}
#define __CALENDARCONVERT__H_typedef struct CalendarStruct
{
CalendarStruct(){}
CalendarStruct(int m_y,int m_m,int m_d)
{
FillThis(m_y,m_m,m_d);
} int year;
int month;
int day;
int week;
BOOL isrunyue; void FillThis(int m_y,int m_m,int m_d)
{
year=m_y;
month=m_m;
day=m_d;
} void FromFile(CFile &m_file)
{
m_file.Read((char *)&year,sizeof(int));
m_file.Read((char *)&month,sizeof(int));
m_file.Read((char *)&day,sizeof(int));
} void ToFile(CFile &m_file)
{
m_file.Write((char *)&year,sizeof(int));
m_file.Write((char *)&month,sizeof(int));
m_file.Write((char *)&day,sizeof(int));
}
}CALENDAR;class CCalendarConvert
{
public:
CCalendarConvert();
~CCalendarConvert();public:
CALENDAR ConvertToGongLi(CALENDAR m_nongli); //将农历日期转化为公历日期
CALENDAR ConvertToNongLi(CALENDAR m_gongli); //将公历日期转化为农历日期
int GetWeekInfo(CALENDAR m_gongli); //根据公历日期计算星期
void MakeCalendar(CALENDAR *m_cal,int y,int m,int d);//填充日期结构的年月日 BOOL GongDataIsValid(CALENDAR m_date); //判断公历日期是否在界内
BOOL NongDataIsValid(CALENDAR m_date); //判断农历日期是否在界内
int GetGongDays(CALENDAR m_start,CALENDAR m_end); //获取公历两个日期之间的天数
int GetNongDays(CALENDAR m_start,CALENDAR m_end); //获取农历两个日期之间的天数 int DaysFromNewYear(CALENDAR m_day); //公历日期到元旦的天数
CALENDAR CalGongDate(int year,int days); //根据天数(到元旦)计算公历日期
int CompareTwoDate(CALENDAR m_fir,CALENDAR m_sec); //比较两个日期的大小
CALENDAR GetCurGongDate(); //将当前公历日期合成为结构
CALENDAR GetDateAfterDays(CALENDAR m_first,int m_days);//当前公历日期后N天的公历日期
int GetNongRunYue(int year); //获取农历闰月
CString GetGanZhi(int m_nongyear); //获取农历年份的干支名称
void NongMonthToList(int m_nongyear,CComboBox & m_list);//将农历年的月份注入组合框
int GetGongMonthDays(int year,int month); //获取公历月的天数
int GetNongMonthDays(int year,int month); //获取农历月的天数
int GetNongMonthDays(int year,int month,BOOL m_run);//获取农历月的天数
int GetNongRunYueDays(int year); //获取农历年闰月天数protected:
int GetGongYearDays(int year); //获取公历年的天数
int GetNongYearDays(int year); //获取农历年的天数
int DaysFromSpringDay(CALENDAR m_day); //农历日期到春节的天数
CALENDAR CalNongDate(int year,int days); //价格天数(到春节)计算农历日期 BOOL YearIsRunNian(int year); //公历年是否闰年
BOOL RunYueIsLarge(int year); //判断闰月是否为大月 BOOL MonthIsRunYue(int year,int month); //判断是否是闰月
BOOL NongMonthIsLarge(int year,int month); //判断农历年的月份是否为大月
BOOL GongMonthIsLarge(int month); //判断公历月份是否为大月(二月除外)
int GetDaysFromStart(int year); //农历大年初一到元旦的天数 int Cal2N(int n); //计算2的N次方
CString GetNNameIn60(int index); //获取60年中的第N年的天干地支名称private:
int m_maxyear; //支持的最大年份
int m_minyear; //支持的最小年份
char **CalendarData; //公农历转化数据
};
#endif