CalendarEx.h 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /************************************************************************/
  2. /*
  3. 文件名称: CalendarEx.h
  4. 文件标识:
  5. 内容摘要: 日期转换类;
  6. 其它说明: 无
  7. 当前版本: V 0.1
  8. 作 者: Jeff
  9. 完成日期: 2015年05月14日
  10. 修改记录1:
  11. 修改日期:-
  12. 版 本 号:-
  13. 修 改 人:-
  14. 修改内容:-
  15. */
  16. /************************************************************************/
  17. #ifndef __CALENDAREX_HEADER__
  18. #define __CALENDAREX_HEADER__
  19. #include <ctime>
  20. #include <cassert>
  21. #include <cstring>
  22. #include <iostream>
  23. using namespace std;
  24. //保存一个农历日期;
  25. typedef struct _STDATE_
  26. {
  27. int year;
  28. int month;
  29. int day;
  30. bool leap; //是否闰月;
  31. } Date;
  32. #pragma once
  33. class CCalendarEx
  34. {
  35. CCalendarEx();
  36. public:
  37. ~CCalendarEx();
  38. static CCalendarEx* GetInstnace()
  39. {
  40. static CCalendarEx tagInstance;
  41. return &tagInstance;
  42. }
  43. int DayOfSolarYear(int year, int month, int day);
  44. bool IsValidLunanrDate(int lunar_year, int lunar_month, int lunar_day);
  45. // 公历转农历;
  46. Date SolarToLuanrDate(int solar_year, int solar_month, int solar_day);
  47. CString GetLunarDate(int solar_year, int solar_month, int solar_day);
  48. // 农历转公历;
  49. CString LuanrToSolarDate(int lunar_year, int lunar_month, int lunar_day, BOOL bLeap = FALSE);
  50. };
  51. #endif