CalendarEx.h 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. #ifndef __CALENDAREX_20160127__
  2. #define __CALENDAREX_20160127__
  3. #pragma once
  4. #ifndef IN
  5. #define IN
  6. #endif
  7. #ifndef OUT
  8. #define OUT
  9. #endif
  10. namespace CalendarEx
  11. {
  12. //保存一个农历日期;
  13. typedef struct _STLUNARDATE_
  14. {
  15. int nYear;
  16. int nMonth;
  17. int nDay;
  18. bool bIsLeapMonth; //是否闰月;
  19. _STLUNARDATE_() {
  20. nYear = 0;
  21. nMonth = 0;
  22. nDay = 0;
  23. bIsLeapMonth = false;
  24. }
  25. } LunarDate, *pLunarDate;
  26. // 农历日期有效性;
  27. bool IsValidLunanrDate(IN const TCHAR* lpLunarDate );
  28. // 农历日期有效性;
  29. bool IsValidLunanrDate(IN const int &nLunarYear, IN const int &nLunarMonth, IN const int &nLunarDay);
  30. // 公历日期有效性;
  31. bool IsValidSolarDate(IN const TCHAR* lpSolarDate);
  32. // 公历日期有效性;
  33. bool IsValidSolarDate(
  34. IN const int &nSolarYear,
  35. IN const int &nSolarMonth,
  36. IN const int &nSolarDay);
  37. // 返回指定日期在当年的第几天;
  38. int DayOfSolarYear(
  39. IN const int &nSolarYear,
  40. IN const int &nSolarMonth,
  41. IN const int &nSolarDay);
  42. // 返回指定日期在当年的第几周;
  43. int DayOfSolarWeek(
  44. IN const int &nSolarYear,
  45. IN const int &nSolarMonth,
  46. IN const int &nSolarDay);
  47. // 公历转农历;
  48. bool SolarToLuanrDate(
  49. IN const int &nSolarYear,
  50. IN const int &nSolarMonth,
  51. IN const int &nSolarDay,
  52. OUT LunarDate &lnaDate);
  53. // 公历转农历;
  54. bool SolarToLuanrDate(
  55. IN const int &nSolarYear,
  56. IN const int &nSolarMonth,
  57. IN const int &nSolarDay,
  58. OUT TCHAR* lpLunarDate);
  59. // 农历转公历;
  60. bool LuanrToSolarDate(
  61. IN const int &nLunarYear,
  62. IN const int &nLunarMonth,
  63. IN const int &nLunarDay,
  64. OUT LunarDate &lnaDate,
  65. IN bool bIsLeapMonth = false );
  66. bool LuanrToSolarDate(
  67. IN const int &nLunarYear,
  68. IN const int &nLunarMonth,
  69. IN const int &nLunarDay,
  70. OUT TCHAR* lpSolarDate,
  71. IN bool bIsLeapMonth = false );
  72. bool LuanrToSolarDate( IN const TCHAR* lpLunarDate, OUT TCHAR* lpSolarDate, IN bool bIsLeapMonth = false);
  73. // 返回某一年的闰月月份;
  74. int IsLeapMonth(IN const int &nLunarYear);
  75. // 计算年龄,返回周岁;
  76. int GetAge(IN const TCHAR* lpLunarBirthDay, IN bool bIsLeapMonth = false);
  77. };
  78. #endif