libcdos-fw
CFLunar.h
1 #ifndef __CFLUNAR_H__
2 #define __CFLUNAR_H__
3 
4 #include <Core/CFTypes.h>
5 
6 extern const CFUInt16 LUNAR_START_YEAR;
7 extern const CFUInt16 LUNAR_END_YEAR;
8 
9 class CFLunar {
10 private:
11  CFUInt16 m_year, m_month, m_day;
12  void l_initData();
13  static void l_calcLunarDate(CFUInt16 &iYear, CFUInt16 &iMonth ,
14  CFUInt16 &iDay,long iSpanDays);
15  static CFUInt16 l_getLunarHolDay(CFUInt16 iYear, CFUInt16 iMonth,
16  CFUInt16 iDay);
17 
18 public:
19  CFLunar(CFUInt16 iYear, CFUInt16 iMonth, CFUInt16 iDay);
20  CFLunar();
21  CFUInt16 getYear() {return m_year;}
22  CFUInt16 getMonth() {return m_month;}
23  CFUInt16 getDay() {return m_day;}
24 
25  void getDate(CFUInt16 &iYear, CFUInt16 &iMonth, CFUInt16 &iDay);
26  int setDate(CFUInt16 iYear, CFUInt16 iMonth, CFUInt16 iDay);
27 
28  static int isLeapYear(CFUInt16 iYear) {return !(iYear%4)&&(iYear%100) || !(iYear%400);}
29  static CFUInt16 weekDay(CFUInt16 iYear, CFUInt16 iMonth, CFUInt16 iDay);
30  static void formatWeekDay (CFUInt16 iYear, CFUInt16 iMonth, CFUInt16 iDay, char *pBuffer);
31  static CFUInt16 monthDays(CFUInt16 iYear, CFUInt16 iMonth);
32 
33  static long lunarMonthDays(CFUInt16 iLunarYear, CFUInt16 iLunarMonth);
34  static CFUInt16 lunarYearDays(CFUInt16 iLunarYear);
35 
36  static CFUInt16 getLeapMonth(CFUInt16 iLunarYear);
37  static bool getFormatLeapMonth (CFUInt16 iLunarYear, char *pBuffer);
38 
39  static void formatLunarYear(CFUInt16 iLunarYear, char *pBuffer);
40  static void formatLunarMonth(CFUInt16 iLunarMonth, char *pBuffer);
41  static void formatLunarDay(CFUInt16 iLunarDay, char *pBuffer);
42 
43  static long calcDateDiff(CFUInt16 iEndYear, CFUInt16 iEndMonth,
44  CFUInt16 iEndDay, CFUInt16 iStartYear = LUNAR_START_YEAR,
45  CFUInt16 iStartMonth = 1, CFUInt16 iStartDay = 1);
46 
47  static void getLunarDate(CFUInt16 iYear, CFUInt16 iMonth,
48  CFUInt16 iDay, CFUInt16 &iLunarYear,
49  CFUInt16 &iLunarMonth, CFUInt16 &iLunarDay);
50  static void getFormatLunarDate (CFUInt16 iYear, CFUInt16 iMonth, CFUInt16 iDay, char *pBuffer);
51 
52  static bool getSolarTerm (CFUInt16 iYear, CFUInt16 iMonth, CFUInt16 iDay, char *pBuffer);
53 };
54 #endif //__CFLUNAR_H__
Definition: CFLunar.h:9
结构与枚举类型定义.