Asp.Net教程,WinForm教程,Asp.Net MVC,vs2008教程,vs2010教程,Silverlight技术,源码下载,Asp.Net视频教程
全站热门标签
vs2010 Silverlight 存储过程 水晶报表 ADO.NET JavaScript LINQ AjaxPro DataGridView 面向对象 Extjs GridView XML DevExpress HTML教程 Oracle jQuery 分页 GDI+ Visual C++2010 MySQL Office2010 WPF MVC Dojo WCF4.0 VB.NET Sql2005 textbox cookie WCF WinForm Discuz!NT SQL经典语句 T-SQL checkbox ASPxGridView F# asp.net SQL VS2008新特性 DropDownList Access TreeView Ajax VS2008 页面执行时间 Flex 字符串 回调 VB2005 DataSet C#时间 ASP.NET性能优化 用户在线检测 动画
Framework C#技术 VB.NETVC.NET WCF WPF
当前位置: 主页 > WinForm教程 > VC.NET >

公农历转换类[C++]

时间:2010-08-18 21:04来源:未知 作者:admin 点击:

头文件:

  1. #ifndef XDATE_H 
  2. #define XDATE_H  
  3.  
  4. #include <windows.h> 
  5. extern const WORD START_YEAR; 
  6. extern const WORD END_YEAR ; 
  7.  
  8. class xDate 
  9. private
  10.    WORD    m_iYear, m_iMonth, m_iDay; 
  11.    void    l_InitData(); 
  12.    //计算从1901年1月1日过iSpanDays天后的阴历日期    
  13.    static void   l_CalcLunarDate(WORD &iYear, WORD &iMonth ,WORD &iDay,LONG iSpanDays); 
  14.    //计算公历iYear年iMonth月iDay日对应的节气 0-24,0表不是节气 
  15.    static WORD   l_GetLunarHolDay(WORD iYear, WORD iMonth, WORD iDay); 
  16. public:  
  17.    //=====================================================================================// 
  18.    xDate(WORD iYear, WORD iMonth, WORD iDay);  
  19.    xDate(); 
  20.    //=====================================================================================// 
  21.  
  22.    WORD GetYear(){return m_iYear;}  
  23.    WORD GetMonth(){return m_iMonth;} 
  24.    WORD GetDay(){return m_iDay;}  
  25.     
  26.    //=====================================================================================// 
  27.    void GetDate(WORD &iYear, WORD &iMonth, WORD &iDay);  
  28.    BOOL SetDate(WORD iYear , WORD iMonth , WORD iDay); 
  29.    //=====================================================================================// 
  30.    //判断iYear是不是闰年  
  31.     static BOOL IsLeapYear(WORD iYear)  {return !(iYear%4)&&(iYear%100) || !(iYear%400);}  
  32.     
  33.    //计算iYear,iMonth,iDay对应是星期几 1年1月1日 --- 65535年12月31日  
  34.    static WORD WeekDay(WORD iYear, WORD iMonth, WORD iDay); 
  35.     
  36.    //返回iYear年iMonth月的天数 1年1月 --- 65535年12月  
  37.    static WORD MonthDays(WORD iYear, WORD iMonth);  
  38.     
  39.    //返回阴历iLunarYer年阴历iLunarMonth月的天数,如果iLunarMonth为闰月, 
  40.    //高字为第二个iLunarMonth月的天数,否则高字为0  
  41.    // 1901年1月---2050年12月  
  42.    static LONG LunarMonthDays(WORD iLunarYear, WORD iLunarMonth);  
  43.     
  44.    //返回阴历iLunarYear年的总天数 
  45.    // 1901年1月---2050年12月  
  46.    static WORD LunarYearDays(WORD iLunarYear);  
  47.     
  48.    //返回阴历iLunarYear年的闰月月份,如没有返回0  
  49.    // 1901年1月---2050年12月 
  50.    static WORD GetLeapMonth(WORD iLunarYear);  
  51.     
  52.    //把iYear年格式化成天干记年法表示的字符串  
  53.    static void FormatLunarYear(WORD  iYear, char *pBuffer);  
  54.  
  55.    //把iMonth格式化成中文字符串  
  56.    static void FormatMonth(WORD iMonth, char *pBuffer, BOOL bLunar = TRUE);  
  57.     
  58.    //把iDay格式化成中文字符串  
  59.    static void FormatLunarDay(WORD  iDay, char *pBuffer); 
  60.     
  61.    //计算公历两个日期间相差的天数  1年1月1日 --- 65535年12月31日  
  62.    static LONG CalcDateDiff(WORD iEndYear, WORD iEndMonth, WORD iEndDay,WORD iStartYear = START_YEAR,WORD iStartMonth =1, WORD iStartDay =1);  
  63.     
  64.    //计算公历iYear年iMonth月iDay日对应的阴历日期,返回对应的阴历节气 0-24 
  65.    //1901年1月1日---2050年12月31日  
  66.    static WORD GetLunarDate(WORD iYear, WORD iMonth, WORD iDay,WORD &iLunarYear, WORD &iLunarMonth, WORD &iLunarDay); 
  67. };  
  68.  
  69. #endif //XDATE_H  

(责任编辑:admin)

Tags:公农历转换
责任编辑:admin
返回顶部
------分隔线----------------------------
推荐内容
骆驼户外男 真皮磨砂日常休闲鞋 低帮 2011秋冬新款 专柜正品特价 骆驼户外男 真皮磨砂日常休闲鞋 低帮 2011秋冬新款 专柜正品特价