载入中,请稍候……

公农历转换类(C#)

Admin 于 2008-10-18 22:05:42 发表.NET

订阅: http://www.miniboke.com/Feed/Article_72.aspx
引用: http://www.miniboke.com/Trackback/WewFlKVRSZjSHdHaOyEP.aspx (UTF-8)
使用代理时服务变量的变化 < 公农历转换类(C#) > 一个C++英文简历

  1. using System; 
  2. namespace ExpertLib.ChinaSpecial 
  3.     #region ChineseCalendarException 
  4.     /// <summary> 
  5.     /// 中国日历异常处理 
  6.     /// </summary> 
  7.     public class ChineseCalendarException : System.Exception 
  8.     { 
  9.         public ChineseCalendarException(string msg) :base(msg) 
  10.         { 
  11.         } 
  12.     } 
  13.  
  14.     #endregion 
  15.  
  16.     /// <summary> 
  17.     /// 中国农历类 版本V1.0 支持 1900.1.31日起至 2049.12.31日止的数据 
  18.     /// </summary> 
  19.     /// <remarks> 
  20.     /// 本程序使用数据来源于网上的万年历查询,并综合了一些其它数据 
  21.     /// </remarks> 
  22.     public class ChineseCalendar 
  23.     { 
  24.         #region 内部结构 
  25.         private struct SolarHolidayStruct 
  26.         { 
  27.             public int Month; 
  28.             public int Day; 
  29.             public int Recess; //假期长度 
  30.             public string HolidayName; 
  31.             public SolarHolidayStruct(int month,int day, int recess, string name) 
  32.             { 
  33.                 Month = month; 
  34.                 Day =day; 
  35.                 Recess = recess; 
  36.                 HolidayName = name; 
  37.             } 
  38.         } 
  39.  
  40.         private struct LunarHolidayStruct 
  41.         { 
  42.             public int Month; 
  43.             public int Day; 
  44.             public int Recess; 
  45.             public string HolidayName; 
  46.  
  47.             public LunarHolidayStruct(int month,int day, int recess, string name) 
  48.             { 
  49.                 Month = month; 
  50.                 Day =day; 
  51.                 Recess = recess; 
  52.                 HolidayName = name; 
  53.             } 
  54.         } 
  55.  
  56.         private struct WeekHolidayStruct 
  57.         { 
  58.             public int Month; 
  59.             public int WeekAtMonth; 
  60.             public int WeekDay; 
  61.             public string HolidayName; 
  62.             
  63.             public WeekHolidayStruct(int month,int weekAtMonth, int weekDay, string name) 
  64.             { 
  65.                 Month = month; 
  66.                 WeekAtMonth=weekAtMonth; 
  67.                 WeekDay = weekDay; 
  68.                 HolidayName = name; 
  69.             } 
  70.         } 
  71.         #endregion 
  72.  
  73.         #region 内部变量 
  74.         private DateTime _date; 
  75.  
  76.         private int _cYear;  
  77.         private int _cMonth; 
  78.         private int _cDay; 
  79.         private bool _cIsLeapMonth; //当月是否闰月 
  80.         private bool _cIsLeapYear; //当年是否有闰月 
  81.         #endregion 
  82.  
  83.         #region 基础数据 
  84.         #region 基本常量 
  85.         private const int MinYear = 1900; 
  86.         private const int MaxYear = 2050; 
  87.         private static  DateTime MinDay = new DateTime(1900,1,30); 
  88.         private static  DateTime MaxDay = new DateTime(2049,12,31); 
  89.         private const int GanZhiStartYear = 1864; //干支计算起始年 
  90.         private static DateTime GanZhiStartDay = new DateTime(1899, 12, 22);//起始日 
  91.         private const string HZNum = "零一二三四五六七八九"
  92.         private const int AnimalStartYear = 1900; //1900年为鼠年 
  93.         #endregion 
  94.     
  95.         #region 阴历数据 
  96.         /// <summary> 
  97.         /// 来源于网上的农历数据 
  98.         /// </summary> 
  99.         /// <remarks> 
  100.         /// 数据结构如下,共使用17位数据 
  101.         /// 第17位:表示闰月天数,0表示29天   1表示30天 
  102.         /// 第16位-第5位(共12位)表示12个月,其中第16位表示第一月,如果该月为30天则为1,29天为0 
  103.         /// 第4位-第1位(共4位)表示闰月是哪个月,如果当年没有闰月,则置0 
  104.         ///</remarks> 
  105.         private static int[] LunarDateArray = new int[]{ 
  106.                 0x04BD8,0x04AE0,0x0A570,0x054D5,0x0D260,0x0D950,0x16554,0x056A0,0x09AD0,0x055D2, 
  107.                 0x04AE0,0x0A5B6,0x0A4D0,0x0D250,0x1D255,0x0B540,0x0D6A0,0x0ADA2,0x095B0,0x14977, 
  108.                 0x04970,0x0A4B0,0x0B4B5,0x06A50,0x06D40,0x1AB54,0x02B60,0x09570,0x052F2,0x04970, 
  109.                 0x06566,0x0D4A0,0x0EA50,0x06E95,0x05AD0,0x02B60,0x186E3,0x092E0,0x1C8D7,0x0C950, 
  110.                 0x0D4A0,0x1D8A6,0x0B550,0x056A0,0x1A5B4,0x025D0,0x092D0,0x0D2B2,0x0A950,0x0B557, 
  111.                 0x06CA0,0x0B550,0x15355,0x04DA0,0x0A5B0,0x14573,0x052B0,0x0A9A8,0x0E950,0x06AA0, 
  112.                 0x0AEA6,0x0AB50,0x04B60,0x0AAE4,0x0A570,0x05260,0x0F263,0x0D950,0x05B57,0x056A0, 
  113.                 0x096D0,0x04DD5,0x04AD0,0x0A4D0,0x0D4D4,0x0D250,0x0D558,0x0B540,0x0B6A0,0x195A6, 
  114.                 0x095B0,0x049B0,0x0A974,0x0A4B0,0x0B27A,0x06A50,0x06D40,0x0AF46,0x0AB60,0x09570, 
  115.                 0x04AF5,0x04970,0x064B0,0x074A3,0x0EA50,0x06B58,0x055C0,0x0AB60,0x096D5,0x092E0, 
  116.                 0x0C960,0x0D954,0x0D4A0,0x0DA50,0x07552,0x056A0,0x0ABB7,0x025D0,0x092D0,0x0CAB5, 
  117.                 0x0A950,0x0B4A0,0x0BAA4,0x0AD50,0x055D9,0x04BA0,0x0A5B0,0x15176,0x052B0,0x0A930, 
  118.                 0x07954,0x06AA0,0x0AD50,0x05B52,0x04B60,0x0A6E6,0x0A4E0,0x0D260,0x0EA65,0x0D530, 
  119.                 0x05AA0,0x076A3,0x096D0,0x04BD7,0x04AD0,0x0A4D0,0x1D0B6,0x0D250,0x0D520,0x0DD45, 
  120.                 0x0B5A0,0x056D0,0x055B2,0x049B0,0x0A577,0x0A4B0,0x0AA50,0x1B255,0x06D20,0x0ADA0, 
  121.                 0x14B63        
  122.                 }; 
  123.     
  124.         #endregion 
  125.  
  126.         #region 星座名称 
  127.         private static string[] _constellationName = 
  128.                     { 
  129.                     "白羊座""金牛座""双子座"
  130.                     "巨蟹座""狮子座""处女座"
  131.                     "天秤座""天蝎座""射手座"
  132.                     "摩羯座""水瓶座""双鱼座" 
  133.                     }; 
  134.         #endregion 
  135.  
  136.         #region 二十四节气 
  137.         private static string[] _lunarHolidayName = 
  138.                     { 
  139.                     "小寒""大寒""立春""雨水"
  140.                     "惊蛰""春分""清明""谷雨"
  141.                     "立夏""小满""芒种""夏至"
  142.                     "小暑""大暑""立秋""处暑"
  143.                     "白露""秋分""寒露""霜降"
  144.                     "立冬""小雪""大雪""冬至" 
  145.                     }; 
  146.         #endregion 
  147.  
  148.         #region 节气数据 
  149.         private static string[] SolarTerm = new string[]{"小寒""大寒""立春""雨水""惊蛰""春分""清明""谷雨""立夏""小满""芒种""夏至""小暑""大暑""立秋""处暑""白露""秋分""寒露""霜降""立冬""小雪""大雪""冬至"}; 
  150.         private static int[] sTermInfo = new int[]{0, 21208, 42467, 63836, 85337, 107014, 128867, 150921, 173149, 195551, 218072, 240693, 263343, 285989, 308563, 331033, 353350, 375494, 397447, 419210, 440795, 462224, 483532, 504758}; 
  151.         #endregion 
  152.  
  153.         #region 农历相关数据 
  154.         private static string ganStr = "甲乙丙丁戊己庚辛壬癸"
  155.         private static string zhiStr = "子丑寅卯辰巳午未申酉戌亥"
  156.         private static string animalStr = "鼠牛虎兔龙蛇马羊猴鸡狗猪"
  157.         private static string nStr1 = "日一二三四五六七八九"
  158.         private static string nStr2 = "初十廿卅"
  159.         private static string[] _monthString = 
  160.                 { 
  161.                     "出错","正月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","腊月" 
  162.                 }; 
  163.         #endregion 
  164.        
  165.         #region 按公历计算的节日 
  166.         private static SolarHolidayStruct[] sHolidayInfo = new SolarHolidayStruct[]{ 
  167.             new SolarHolidayStruct(1, 1, 1, "元旦"), 
  168.             new SolarHolidayStruct(2, 2, 0, "世界湿地日"), 
  169.             new SolarHolidayStruct(2, 10, 0, "国际气象节"), 
  170.             new SolarHolidayStruct(2, 14, 0, "情人节"), 
  171.             new SolarHolidayStruct(3, 1, 0, "国际海豹日"), 
  172.             new SolarHolidayStruct(3, 5, 0, "学雷锋纪念日"), 
  173.             new SolarHolidayStruct(3, 8, 0, "妇女节"), 
  174.             new SolarHolidayStruct(3, 12, 0, "植树节 孙中山逝世纪念日"), 
  175.             new SolarHolidayStruct(3, 14, 0, "国际警察日"), 
  176.             new SolarHolidayStruct(3, 15, 0, "消费者权益日"), 
  177.             new SolarHolidayStruct(3, 17, 0, "中国国医节 国际航海日"), 
  178.             new SolarHolidayStruct(3, 21, 0, "世界森林日 消除种族歧视国际日 世界儿歌日"), 
  179.             new SolarHolidayStruct(3, 22, 0, "世界水日"), 
  180.             new SolarHolidayStruct(3, 24, 0, "世界防治结核病日"), 
  181.             new SolarHolidayStruct(4, 1, 0, "愚人节"), 
  182.             new SolarHolidayStruct(4, 7, 0, "世界卫生日"), 
  183.             new SolarHolidayStruct(4, 22, 0, "世界地球日"), 
  184.             new SolarHolidayStruct(5, 1, 1, "劳动节"), 
  185.             new SolarHolidayStruct(5, 2, 1, "劳动节假日"), 
  186.             new SolarHolidayStruct(5, 3, 1, "劳动节假日"), 
  187.             new SolarHolidayStruct(5, 4, 0, "青年节"), 
  188.             new SolarHolidayStruct(5, 8, 0, "世界红十字日"), 
  189.             new SolarHolidayStruct(5, 12, 0, "国际护士节"), 
  190.             new SolarHolidayStruct(5, 31, 0, "世界无烟日"), 
  191.             new SolarHolidayStruct(6, 1, 0, "国际儿童节"), 
  192.             new SolarHolidayStruct(6, 5, 0, "世界环境保护日"), 
  193.             new SolarHolidayStruct(6, 26, 0, "国际禁毒日"), 
  194.             new SolarHolidayStruct(7, 1, 0, "建党节 香港回归纪念 世界建筑日"), 
  195.             new SolarHolidayStruct(7, 11, 0, "世界人口日"), 
  196.             new SolarHolidayStruct(8, 1, 0, "建军节"), 
  197.             new SolarHolidayStruct(8, 8, 0, "中国男子节 父亲节"), 
  198.             new SolarHolidayStruct(8, 15, 0, "抗日战争胜利纪念"), 
  199.             new SolarHolidayStruct(9, 9, 0, "毛泽 东逝世纪念"), 
  200.             new SolarHolidayStruct(9, 10, 0, "教师节"), 
  201.             new SolarHolidayStruct(9, 18, 0, "九·一八事变纪念日"), 
  202.             new SolarHolidayStruct(9, 20, 0, "国际爱牙日"), 
  203.             new SolarHolidayStruct(9, 27, 0, "世界旅游日"), 
  204.             new SolarHolidayStruct(9, 28, 0, "孔子诞辰"), 
  205.             new SolarHolidayStruct(10, 1, 1, "国庆节 国际音乐日"), 
  206.             new SolarHolidayStruct(10, 2, 1, "国庆节假日"), 
  207.             new SolarHolidayStruct(10, 3, 1, "国庆节假日"), 
  208.             new SolarHolidayStruct(10, 6, 0, "老人节"), 
  209.             new SolarHolidayStruct(10, 24, 0, "联合国日"), 
  210.             new SolarHolidayStruct(11, 10, 0, "世界青年节"), 
  211.             new SolarHolidayStruct(11, 12, 0, "孙中山诞辰纪念"), 
  212.             new SolarHolidayStruct(12, 1, 0, "世界艾滋病日"), 
  213.             new SolarHolidayStruct(12, 3, 0, "世界残疾人日"), 
  214.             new SolarHolidayStruct(12, 20, 0, "澳门回归纪念"), 
  215.             new SolarHolidayStruct(12, 24, 0, "平安夜"), 
  216.             new SolarHolidayStruct(12, 25, 0, "圣诞节"), 
  217.             new SolarHolidayStruct(12, 26, 0, "毛泽 东诞辰纪念"
  218.            }; 
  219.         #endregion 
  220.  
  221.         #region 按农历计算的节日 
  222.         private static LunarHolidayStruct[] lHolidayInfo = new LunarHolidayStruct[]{ 
  223.             new LunarHolidayStruct(1, 1, 1, "春节"), 
  224.             new LunarHolidayStruct(1, 15, 0, "元宵节"), 
  225.             new LunarHolidayStruct(5, 5, 0, "端午节"), 
  226.             new LunarHolidayStruct(7, 7, 0, "七夕情人节"), 
  227.             new LunarHolidayStruct(7, 15, 0, "中元节 盂兰盆节"), 
  228.             new LunarHolidayStruct(8, 15, 0, "中秋节"), 
  229.             new LunarHolidayStruct(9, 9, 0, "重阳节"), 
  230.             new LunarHolidayStruct(12, 8, 0, "腊八节"), 
  231.             new LunarHolidayStruct(12, 23, 0, "北方小年(扫房)"), 
  232.             new LunarHolidayStruct(12, 24, 0, "南方小年(掸尘)"), 
  233.             //new LunarHolidayStruct(12, 30, 0, "除夕")  //注意除夕需要其它方法进行计算 
  234.         }; 
  235.         #endregion 
  236.  
  237.         #region 按某月第几个星期几 
  238.         private static WeekHolidayStruct[] wHolidayInfo= new WeekHolidayStruct[]{ 
  239.             new WeekHolidayStruct(5, 2, 1, "母亲节"), 
  240.             new WeekHolidayStruct(5, 3, 1, "全国助残日"), 
  241.             new WeekHolidayStruct(6, 3, 1, "父亲节"), 
  242.             new WeekHolidayStruct(9, 3, 3, "国际和平日"), 
  243.             new WeekHolidayStruct(9, 4, 1, "国际聋人节"), 
  244.             new WeekHolidayStruct(10, 1, 2, "国际住房日"), 
  245.             new WeekHolidayStruct(10, 1, 4, "国际减轻自然灾害日"), 
  246.             new WeekHolidayStruct(11, 4, 5, "感恩节"
  247.         }; 
  248.         #endregion 
  249.  
  250.         #endregion 
  251.  
  252.         #region 构造函数 
  253.         #region ChinaCalendar <公历日期初始化> 
  254.         /// <summary> 
  255.         /// 用一个标准的公历日期来初使化 
  256.         /// </summary> 
  257.         /// <param name="dt"></param> 
  258.         public ChineseCalendar(DateTime dt) 
  259.         { 
  260.             int i; 
  261.             int leap; 
  262.             int temp; 
  263.             int offset; 
  264.  
  265.             CheckDateLimit(dt); 
  266.            
  267.             _date = dt.Date; 
  268.             
  269.             //农历日期计算部分 
  270.             leap = 0; 
  271.             temp = 0; 
  272.  
  273.             TimeSpan ts = _date - ChineseCalendar.MinDay;//计算两天的基本差距 
  274.             offset = ts.Days; 
  275.  
  276.             for (i = MinYear; i <= MaxYear; i++) 
  277.             { 
  278.                 temp = GetChineseYearDays(i);  //求当年农历年天数 
  279.                 if (offset - temp < 1) 
  280.                     break
  281.                 else 
  282.                 { 
  283.                     offset = offset - temp; 
  284.                 } 
  285.             } 
  286.             _cYear = i; 
  287.  
  288.             leap = GetChineseLeapMonth(_cYear);//计算该年闰哪个月 
  289.             //设定当年是否有闰月 
  290.             if (leap > 0) 
  291.             { 
  292.                 _cIsLeapYear = true
  293.             } 
  294.             else 
  295.             { 
  296.                 _cIsLeapYear = false
  297.             } 
  298.  
  299.             _cIsLeapMonth = false
  300.             for (i = 1; i <= 12; i++) 
  301.             { 
  302.                 //闰月 
  303.                 if ((leap > 0) && (i == leap + 1) && (_cIsLeapMonth == false)) 
  304.                 { 
  305.                     _cIsLeapMonth = true
  306.                     i = i - 1; 
  307.                     temp = GetChineseLeapMonthDays(_cYear); //计算闰月天数 
  308.                 } 
  309.                 else 
  310.                 { 
  311.                     _cIsLeapMonth = false
  312.                     temp = GetChineseMonthDays(_cYear, i);//计算非闰月天数 
  313.                 } 
  314.  
  315.                 offset = offset - temp; 
  316.                 if (offset <= 0) break
  317.             } 
  318.  
  319.             offset = offset + temp; 
  320.             _cMonth = i; 
  321.             _cDay = offset; 
  322.         } 
  323.         #endregion 
  324.  
  325.         #region ChinaCalendar <农历日期初始化> 
  326.         /// <summary> 
  327.         /// 用农历的日期来初使化 
  328.         /// </summary> 
  329.         /// <param name="cy">农历年</param> 
  330.         /// <param name="cm">农历月</param> 
  331.         /// <param name="cd">农历日</param> 
  332.         /// <param name="LeapFlag">闰月标志</param> 
  333.         public ChineseCalendar(int cy, int cm, int cd, bool leapMonthFlag) 
  334.         { 
  335.             int i,leap,Temp,offset; 
  336.  
  337.             CheckChineseDateLimit(cy, cm, cd, leapMonthFlag); 
  338.  
  339.             _cYear = cy; 
  340.             _cMonth = cm; 
  341.             _cDay = cd; 
  342.             
  343.             offset = 0; 
  344.     
  345.             for(i = MinYear ;i< cy ;i++) 
  346.             { 
  347.                Temp = GetChineseYearDays(i); //求当年农历年天数 
  348.                offset = offset + Temp; 
  349.             } 
  350.         
  351.             leap = GetChineseLeapMonth(cy);// 计算该年应该闰哪个月 
  352.             if (leap != 0) 
  353.             { 
  354.                 this._cIsLeapYear = true
  355.             } 
  356.             else 
  357.             { 
  358.                 this._cIsLeapYear = false
  359.             } 
  360.  
  361.             if( cm != leap) 
  362.             { 
  363.                _cIsLeapMonth = false;  //当前日期并非闰月 
  364.             } 
  365.             else 
  366.             { 
  367.                _cIsLeapMonth = leapMonthFlag;  //使用用户输入的是否闰月月份 
  368.             } 
  369.  
  370.  
  371.             if ( (_cIsLeapYear == false) || //当年没有闰月 
  372.                  (cm < leap )) //计算月份小于闰月     
  373.             { 
  374.                 #region ... 
  375.                 for (i = 1; i < cm ; i++) 
  376.                 { 
  377.                     Temp = GetChineseMonthDays(cy, i);//计算非闰月天数 
  378.                     offset = offset + Temp; 
  379.                 } 
  380.  
  381.                 //检查日期是否大于最大天 
  382.                 if (cd > GetChineseMonthDays(cy, cm)) 
  383.                 { 
  384.                     throw new ChineseCalendarException("不合法的农历日期"); 
  385.                 } 
  386.                 offset = offset + cd; //加上当月的天数 
  387.                 #endregion 
  388.             } 
  389.             else   //是闰年,且计算月份大于或等于闰月 
  390.             { 
  391.                 #region ... 
  392.                 for (i = 1; i < cm ; i++) 
  393.                 { 
  394.                     Temp = GetChineseMonthDays(cy, i); //计算非闰月天数 
  395.                     offset = offset + Temp; 
  396.                 } 
  397.  
  398.                 if (cm > leap) //计算月大于闰月 
  399.                 {                    
  400.                     Temp = GetChineseLeapMonthDays(cy);   //计算闰月天数 
  401.                     offset = offset + Temp;               //加上闰月天数 
  402.  
  403.                     if (cd > GetChineseMonthDays(cy, cm)) 
  404.                     { 
  405.                         throw new ChineseCalendarException("不合法的农历日期"); 
  406.                     } 
  407.                     offset = offset + cd; 
  408.                 } 
  409.                 else  //计算月等于闰月 
  410.                 { 
  411.                     //如果需要计算的是闰月,则应首先加上与闰月对应的普通月的天数 
  412.                     if (this._cIsLeapMonth == true//计算月为闰月 
  413.                     { 
  414.                         Temp = GetChineseMonthDays(cy, cm); //计算非闰月天数 
  415.                         offset = offset + Temp; 
  416.                     } 
  417.  
  418.                     if (cd > GetChineseLeapMonthDays(cy)) 
  419.                     { 
  420.                         throw new ChineseCalendarException("不合法的农历日期"); 
  421.                     } 
  422.                     offset = offset + cd; 
  423.                 } 
  424.                 #endregion 
  425.             } 
  426.  
  427.            
  428.            _date=MinDay.AddDays(offset); 
  429.        } 
  430.         #endregion 
  431.         #endregion 
  432.  
  433.         #region 私有函数 
  434.  
  435.         #region GetChineseMonthDays 
  436.         //传回农历 y年m月的总天数 
  437.         private int GetChineseMonthDays(int year , int month ) 
  438.         { 
  439.             if( BitTest32((LunarDateArray[year - MinYear] & 0x0000FFFF) , (16 - month))) 
  440.             { 
  441.                 return 30; 
  442.             } 
  443.             else 
  444.             { 
  445.                 return 29; 
  446.             } 
  447.         } 
  448.         #endregion 
  449.  
  450.         #region GetChineseLeapMonth 
  451.         //传回农历 y年闰哪个月 1-12 , 没闰传回 0 
  452.         private int GetChineseLeapMonth(int year) 
  453.         { 
  454.             
  455.             return LunarDateArray[year - MinYear] & 0xF; 
  456.  
  457.         } 
  458.         #endregion 
  459.  
  460.         #region GetChineseLeapMonthDays 
  461.         //传回农历 y年闰月的天数 
  462.         private int GetChineseLeapMonthDays(int year) 
  463.         { 
  464.             if(GetChineseLeapMonth(year)!=0) 
  465.             { 
  466.                 if((LunarDateArray[year - MinYear] & 0x10000) !=0) 
  467.                 { 
  468.                     return 30; 
  469.                 } 
  470.                 else 
  471.                 { 
  472.                     return 29; 
  473.                 } 
  474.             } 
  475.             else 
  476.             { 
  477.                 return 0; 
  478.             } 
  479.         } 
  480.         #endregion 
  481.  
  482.         #region GetChineseYearDays 
  483.         /// <summary> 
  484.         /// 取农历年一年的天数 
  485.         /// </summary> 
  486.         /// <param name="year"></param> 
  487.         /// <returns></returns> 
  488.         private int GetChineseYearDays(int year) 
  489.         { 
  490.             int i,f,sumDay,info; 
  491.  
  492.             sumDay=348; //29天 X 12个月 
  493.             i=0x8000; 
  494.             info = LunarDateArray[year - MinYear] & 0x0FFFF; 
  495.  
  496.             //计算12个月中有多少天为30天 
  497.             for (int m = 0; m < 12; m++) 
  498.             { 
  499.                 f = info & i; 
  500.                 if (f != 0) 
  501.                 { 
  502.                     sumDay++; 
  503.                 } 
  504.                 i = i >> 1; 
  505.             } 
  506.             return sumDay+ GetChineseLeapMonthDays(year); 
  507.         } 
  508.         #endregion 
  509.  
  510.         #region CheckDateLimit 
  511.         /// <summary> 
  512.         /// 检查公历日期是否符合要求 
  513.         /// </summary> 
  514.         /// <param name="dt"></param> 
  515.         private void CheckDateLimit(DateTime dt) 
  516.         { 
  517.             if ((dt < MinDay) || (dt > MaxDay)) 
  518.             { 
  519.                 throw new ChineseCalendarException("超出可转换的日期"); 
  520.             } 
  521.         } 
  522.         #endregion 
  523.         
  524.         #region CheckChineseDateLimit 
  525.         /// <summary> 
  526.         /// 检查农历日期是否合理 
  527.         /// </summary> 
  528.         /// <param name="year"></param> 
  529.         /// <param name="month"></param> 
  530.         /// <param name="day"></param> 
  531.         /// <param name="leapMonth"></param> 
  532.         private void CheckChineseDateLimit(int year,int month,int day, bool leapMonth) 
  533.         { 
  534.             if( (year < MinYear) || (year > MaxYear) ) 
  535.             { 
  536.                 throw new ChineseCalendarException("非法农历日期"); 
  537.             } 
  538.             if ((month < 1) || (month > 12)) 
  539.             { 
  540.                 throw new ChineseCalendarException("非法农历日期"); 
  541.             } 
  542.             if ((day < 1) || (day > 30)) //中国的月最多30天 
  543.             { 
  544.                 throw new ChineseCalendarException("非法农历日期"); 
  545.             } 
  546.  
  547.             int leap = GetChineseLeapMonth(year);// 计算该年应该闰哪个月 
  548.             if ( (leapMonth == true) &&( month != leap)) 
  549.             { 
  550.                 throw new ChineseCalendarException("非法农历日期"); 
  551.             } 
  552.             
  553.             
  554.         } 
  555.         #endregion 
  556.  
  557.         #region ConvertNumToChineseNum 
  558.         /// <summary> 
  559.         /// 将0-9转成汉字形式 
  560.         /// </summary> 
  561.         /// <param name="n"></param> 
  562.         /// <returns></returns> 
  563.         private string ConvertNumToChineseNum(char n) 
  564.         { 
  565.             if ((n<'0')||(n > '9')) return ""
  566.             switch (n) 
  567.             { 
  568.                 case '0'
  569.                     return HZNum[0].ToString(); 
  570.                 case '1'
  571.                     return HZNum[1].ToString(); 
  572.                 case '2'
  573.                     return HZNum[2].ToString(); 
  574.                 case '3'
  575.                     return HZNum[3].ToString(); 
  576.                 case '4'
  577.                     return HZNum[4].ToString(); 
  578.                 case '5'
  579.                     return HZNum[5].ToString(); 
  580.                 case '6'
  581.                     return HZNum[6].ToString(); 
  582.                 case '7'
  583.                     return HZNum[7].ToString(); 
  584.                 case '8'
  585.                     return HZNum[8].ToString(); 
  586.                 case '9'
  587.                     return HZNum[9].ToString(); 
  588.                 default
  589.                     return ""
  590.             } 
  591.         } 
  592.         #endregion 
  593.  
  594.         #region BitTest32 
  595.         /// <summary> 
  596.         /// 测试某位是否为真 
  597.         /// </summary> 
  598.         /// <param name="num"></param> 
  599.         /// <param name="bitpostion"></param> 
  600.         /// <returns></returns> 
  601.         private bool BitTest32(int num, int bitpostion) 
  602.         { 
  603.             
  604.             if ( (bitpostion > 31) || (bitpostion < 0)) 
  605.                 throw new Exception("Error Param: bitpostion[0-31]:"+ bitpostion.ToString()); 
  606.             
  607.             int bit = 1 << bitpostion; 
  608.             
  609.             if ((num & bit) == 0) 
  610.             { 
  611.                 return false
  612.             } 
  613.             else 
  614.             { 
  615.                 return true
  616.             } 
  617.         } 
  618.         #endregion 
  619.  
  620.         #region ConvertDayOfWeek 
  621.         /// <summary> 
  622.         /// 将星期几转成数字表示 
  623.         /// </summary> 
  624.         /// <param name="dayOfWeek"></param> 
  625.         /// <returns></returns> 
  626.         private int ConvertDayOfWeek(DayOfWeek dayOfWeek) 
  627.         { 
  628.             switch (dayOfWeek) 
  629.             { 
  630.                 case DayOfWeek.Sunday: 
  631.                     return 1; 
  632.                 case DayOfWeek.Monday: 
  633.                     return 2; 
  634.                 case DayOfWeek.Tuesday: 
  635.                     return 3; 
  636.                 case DayOfWeek.Wednesday: 
  637.                     return 4; 
  638.                 case DayOfWeek.Thursday: 
  639.                     return 5; 
  640.                 case DayOfWeek.Friday: 
  641.                     return 6; 
  642.                 case DayOfWeek.Saturday: 
  643.                     return 7; 
  644.                 default
  645.                     return 0; 
  646.             } 
  647.         } 
  648.         #endregion 
  649.  
  650.         #region CompareWeekDayHoliday 
  651.         /// <summary> 
  652.         /// 比较当天是不是指定的第周几 
  653.         /// </summary> 
  654.         /// <param name="date"></param> 
  655.         /// <param name="month"></param> 
  656.         /// <param name="week"></param> 
  657.         /// <param name="day"></param> 
  658.         /// <returns></returns> 
  659.         private bool CompareWeekDayHoliday(DateTime date, int month, int week, int day) 
  660.         { 
  661.             bool ret = false
  662.             
  663.             if (date.Month == month) //月份相同 
  664.             { 
  665.                 if (ConvertDayOfWeek(date.DayOfWeek) == day) //星期几相同 
  666.                 { 
  667.                     DateTime firstDay = new DateTime(date.Year, date.Month, 1);//生成当月第一天 
  668.                     int i =ConvertDayOfWeek(firstDay.DayOfWeek); 
  669.                     int firWeekDays = 7 - ConvertDayOfWeek(firstDay.DayOfWeek) + 1; //计算第一周剩余天数 
  670.                     
  671.                     if (i > day) 
  672.                     {   
  673.                         if ((week-1) * 7 + day + firWeekDays == date.Day) 
  674.                         { 
  675.                             ret = true
  676.                         } 
  677.                     } 
  678.                     else 
  679.                     { 
  680.                         if ( day + firWeekDays + (week-2) * 7  == date.Day) 
  681.                         { 
  682.                             ret = true
  683.                         } 
  684.                     } 
  685.                 } 
  686.             } 
  687.  
  688.             return ret; 
  689.         } 
  690.         #endregion 
  691.         #endregion 
  692.  
  693.         #region  属性 
  694.  
  695.         #region 节日 
  696.         #region ChineseCalendarHoliday 
  697.         /// <summary> 
  698.         /// 计算中国农历节日 
  699.         /// </summary> 
  700.         public string ChineseCalendarHoliday 
  701.         { 
  702.             get 
  703.             { 
  704.                 string tempStr=""
  705.                 if (this._cIsLeapMonth == false//闰月不计算节日 
  706.                 { 
  707.                     foreach (LunarHolidayStruct lh in lHolidayInfo) 
  708.                     { 
  709.                         if ((lh.Month == this._cMonth) && (lh.Day == this._cDay)) 
  710.                         { 
  711.  
  712.                             tempStr = lh.HolidayName; 
  713.                             break
  714.  
  715.                         } 
  716.                     } 
  717.  
  718.                     //对除夕进行特别处理 
  719.                     if (this._cMonth == 12) 
  720.                     { 
  721.                         int i = GetChineseMonthDays(this._cYear, 12); //计算当年农历12月的总天数 
  722.                         if (this._cDay == i) //如果为最后一天 
  723.                         { 
  724.                             tempStr = "除夕"
  725.                         } 
  726.                     } 
  727.                 } 
  728.                 return tempStr; 
  729.             } 
  730.         } 
  731.         #endregion 
  732.  
  733.         #region WeekDayHoliday 
  734.         /// <summary> 
  735.         /// 按某月第几周第几日计算的节日 
  736.         /// </summary> 
  737.         public string WeekDayHoliday 
  738.         { 
  739.             get 
  740.             { 
  741.                 string tempStr = ""
  742.                 foreach (WeekHolidayStruct wh in wHolidayInfo) 
  743.                 { 
  744.                     if (CompareWeekDayHoliday(_date,wh.Month,wh.WeekAtMonth,wh.WeekDay)) 
  745.                     {   
  746.                             tempStr = wh.HolidayName; 
  747.                             break
  748.                     } 
  749.                 } 
  750.                 return tempStr; 
  751.             } 
  752.         } 
  753.         #endregion 
  754.  
  755.         #region DateHoliday 
  756.         /// <summary> 
  757.         /// 按公历日计算的节日 
  758.         /// </summary> 
  759.         public string DateHoliday 
  760.         { 
  761.             get 
  762.             { 
  763.                 string tempStr = ""
  764.  
  765.                 foreach (SolarHolidayStruct sh in sHolidayInfo) 
  766.                 { 
  767.                     if ((sh.Month == _date.Month) && (sh.Day == _date.Day)) 
  768.                     { 
  769.                         tempStr = sh.HolidayName; 
  770.                         break
  771.                     } 
  772.                 } 
  773.                 return tempStr; 
  774.             } 
  775.         } 
  776.         #endregion 
  777.         #endregion 
  778.  
  779.         #region 公历日期 
  780.         #region Date 
  781.         /// <summary> 
  782.             /// 取对应的公历日期 
  783.             /// </summary> 
  784.             public DateTime Date 
  785.         { 
  786.             get { return _date; } 
  787.             set { _date = value; } 
  788.         } 
  789.         #endregion 
  790.  
  791.         #region WeekDay 
  792.         /// <summary> 
  793.         /// 取星期几 
  794.         /// </summary> 
  795.         public DayOfWeek WeekDay 
  796.         { 
  797.             get { return _date.DayOfWeek; } 
  798.         } 
  799.         #endregion 
  800.  
  801.         #region WeekDayStr 
  802.         /// <summary> 
  803.         /// 周几的字符 
  804.         /// </summary> 
  805.         public string WeekDayStr 
  806.         { 
  807.             get 
  808.             { 
  809.                 switch (_date.DayOfWeek) 
  810.                 { 
  811.                     case DayOfWeek.Sunday: 
  812.                         return "星期日"
  813.                     case DayOfWeek.Monday: 
  814.                         return "星期一"
  815.                     case DayOfWeek.Tuesday: 
  816.                         return "星期二"
  817.                     case DayOfWeek.Wednesday: 
  818.                         return "星期三"
  819.                     case DayOfWeek.Thursday: 
  820.                         return "星期四"
  821.                     case DayOfWeek.Friday: 
  822.                         return "星期五"
  823.                     default
  824.                         return "星期六"
  825.                 } 
  826.             } 
  827.         } 
  828.         #endregion 
  829.  
  830.         #region DateString 
  831.         /// <summary> 
  832.         /// 公历日期中文表示法 如一九九七年七月一日 
  833.         /// </summary> 
  834.         public string DateString 
  835.         { 
  836.             get 
  837.             { 
  838.                 return "公元"this._date.ToLongDateString(); 
  839.             } 
  840.         } 
  841.         #endregion 
  842.  
  843.         #region IsLeapYear 
  844.         /// <summary> 
  845.         /// 当前是否公历闰年 
  846.         /// </summary> 
  847.         public bool IsLeapYear 
  848.         { 
  849.             get 
  850.             { 
  851.                 return DateTime.IsLeapYear(this._date.Year); 
  852.             } 
  853.         } 
  854.         #endregion 
  855.         #endregion 
  856.  
  857.         #region 农历日期 
  858.         #region IsChineseLeapMonth 
  859.         /// <summary> 
  860.         /// 是否闰月 
  861.         /// </summary> 
  862.         public bool IsChineseLeapMonth 
  863.         { 
  864.             get { return this._cIsLeapMonth; } 
  865.         } 
  866.         #endregion 
  867.  
  868.         #region IsChineseLeapYear 
  869.         /// <summary> 
  870.         /// 当年是否有闰月 
  871.         /// </summary> 
  872.         public bool IsChineseLeapYear 
  873.         { 
  874.             get 
  875.             { 
  876.                 return this._cIsLeapYear; 
  877.             } 
  878.         } 
  879.         #endregion 
  880.  
  881.         #region ChineseDay 
  882.         /// <summary> 
  883.         /// 农历日 
  884.         /// </summary> 
  885.         public int ChineseDay 
  886.         { 
  887.             get { return this._cDay; } 
  888.         } 
  889.         #endregion 
  890.  
  891.         #region ChineseDayString 
  892.         /// <summary> 
  893.         /// 农历日中文表示 
  894.         /// </summary> 
  895.         public string ChineseDayString 
  896.         { 
  897.             get 
  898.             { 
  899.                 switch(this._cDay) 
  900.                 { 
  901.                     case 0: 
  902.                         return ""
  903.                     case 10: 
  904.                         return "初十"
  905.                     case 20: 
  906.                         return "二十"
  907.                     case 30: 
  908.                         return "三十"
  909.                     default
  910.                         return nStr2[(int)(_cDay / 10)].ToString() + nStr1[_cDay % 10].ToString(); 
  911.                         
  912.                 } 
  913.             } 
  914.         } 
  915.         #endregion 
  916.  
  917.         #region ChineseMonth 
  918.         /// <summary> 
  919.         /// 农历的月份 
  920.         /// </summary> 
  921.         public int ChineseMonth 
  922.         { 
  923.             get { return this._cMonth; } 
  924.         } 
  925.         #endregion 
  926.  
  927.         #region ChineseMonthString 
  928.         /// <summary> 
  929.         /// 农历月份字符串 
  930.         /// </summary> 
  931.         public string ChineseMonthString 
  932.         { 
  933.             get 
  934.             { 
  935.                 return _monthString[this._cMonth]; 
  936.             } 
  937.         } 
  938.         #endregion 
  939.  
  940.         #region ChineseYear 
  941.         /// <summary> 
  942.         /// 取农历年份 
  943.         /// </summary> 
  944.         public int ChineseYear 
  945.         { 
  946.             get { return this._cYear; } 
  947.         } 
  948.         #endregion 
  949.  
  950.         #region ChineseYearString 
  951.         /// <summary> 
  952.         /// 取农历年字符串如,一九九七年 
  953.         /// </summary> 
  954.         public string ChineseYearString 
  955.         { 
  956.             get 
  957.             { 
  958.                 string tempStr=""
  959.                 string num = this._cYear.ToString(); 
  960.                 for (int i = 0; i < 4; i++) 
  961.                 { 
  962.                     tempStr += ConvertNumToChineseNum(num[i]); 
  963.                 } 
  964.                 return tempStr+"年"
  965.             } 
  966.         } 
  967.         #endregion 
  968.  
  969.         #region ChineseDateString 
  970.         /// <summary> 
  971.         /// 取农历日期表示法:农历一九九七年正月初五 
  972.         /// </summary> 
  973.         public string ChineseDateString 
  974.         { 
  975.             get 
  976.             { 
  977.                 if (this._cIsLeapMonth == true
  978.                 { 
  979.                     return "农历" + ChineseYearString + "闰" + ChineseMonthString + ChineseDayString; 
  980.                 } 
  981.                 else 
  982.                 { 
  983.                     return "农历" + ChineseYearString + ChineseMonthString + ChineseDayString; 
  984.                 } 
  985.             } 
  986.         } 
  987.         #endregion 
  988.  
  989.         #region ChineseTwentyFourDay 
  990.         /// <summary> 
  991.         /// 定气法计算二十四节气,二十四节气是按地球公转来计算的,并非是阴历计算的 
  992.         /// </summary> 
  993.         /// <remarks> 
  994.         /// 节气的定法有两种。古代历法采用的称为"恒气",即按时间把一年等分为24份, 
  995.         /// 每一节气平均得15天有余,所以又称"平气"。现代农历采用的称为"定气",即 
  996.         /// 按地球在轨道上的位置为标准,一周360°,两节气之间相隔15°。由于冬至时地 
  997.         /// 球位于近日点附近,运动速度较快,因而太阳在黄道上移动15°的时间不到15天。 
  998.         /// 夏至前后的情况正好相反,太阳在黄道上移动较慢,一个节气达16天之多。采用 
  999.         /// 定气时可以保证春、秋两分必然在昼夜平分的那两天。 
  1000.         /// </remarks> 
  1001.         public string ChineseTwentyFourDay 
  1002.         { 
  1003.             get 
  1004.             { 
  1005.                 DateTime baseDateAndTime = new DateTime(1900,1,6,2,5,0); //#1/6/1900 2:05:00 AM# 
  1006.                 DateTime newDate; 
  1007.                 double num; 
  1008.                 int y; 
  1009.                 string tempStr=""
  1010.  
  1011.                 y = this._date.Year; 
  1012.  
  1013.                 for(int i=1;i<=24;i++) 
  1014.                 { 
  1015.                     num = 525948.76 * (y - 1900) + sTermInfo[i - 1]; 
  1016.                     
  1017.                     newDate = baseDateAndTime.AddMinutes(num);//按分钟计算 
  1018.                     if( newDate.DayOfYear == _date.DayOfYear) 
  1019.                     { 
  1020.                         tempStr =SolarTerm[i - 1]; 
  1021.                         break
  1022.                     } 
  1023.                 } 
  1024.                 return tempStr; 
  1025.             } 
  1026.         } 
  1027.         #endregion 
  1028.         #endregion 
  1029.         
  1030.         #region 星座 
  1031.         #region Constellation 
  1032.         /// <summary> 
  1033.         /// 计算指定日期的星座序号 
  1034.         /// </summary> 
  1035.         /// <returns></returns> 
  1036.         public string Constellation 
  1037.         { 
  1038.             get
  1039.                 int index=0; 
  1040.                 int y, m, d; 
  1041.                 y = _date.Year; 
  1042.                 m = _date.Month; 
  1043.                 d = _date.Day; 
  1044.                 y = m * 100 + d; 
  1045.                 
  1046.                 if (((y >= 321) && (y <= 419))) { index = 0; } 
  1047.                 else if ((y >= 420) && (y <= 520)) { index = 1; } 
  1048.                 else if ((y >= 521) && (y <= 620)) { index = 2; } 
  1049.                 else if ((y >= 621) && (y <= 722)) { index = 3; } 
  1050.                 else if ((y >= 723) && (y <= 822)) { index = 4; } 
  1051.                 else if ((y >= 823) && (y <= 922)) { index = 5; } 
  1052.                 else if ((y >= 923) && (y <= 1022)) { index = 6; } 
  1053.                 else if ((y >= 1023) && (y <= 1121)) { index = 7; } 
  1054.                 else if ((y >= 1122) && (y <= 1221)) { index = 8; } 
  1055.                 else if ((y >= 1222) || (y <= 119)) { index = 9; } 
  1056.                 else if ((y >= 120) && (y <= 218)) { index = 10; } 
  1057.                 else if ((y >= 219) && (y <= 320)) { index = 11; } 
  1058.                 else { index = 0; } 
  1059.  
  1060.                 return _constellationName[index]; 
  1061.             } 
  1062.         } 
  1063.         #endregion 
  1064.         #endregion 
  1065.  
  1066.         #region 属相 
  1067.         #region Animal 
  1068.         /// <summary> 
  1069.         /// 计算属相的索引,注意虽然属相是以农历年来区别的,但是目前在实际使用中是按公历来计算的 
  1070.         /// 鼠年为1,其它类推 
  1071.         /// </summary> 
  1072.         public int Animal 
  1073.         { 
  1074.             get 
  1075.             { 
  1076.                 int offset = _date.Year - AnimalStartYear; 
  1077.                 return (offset % 12) + 1; 
  1078.             } 
  1079.         } 
  1080.         #endregion 
  1081.  
  1082.         #region AnimalString 
  1083.         /// <summary> 
  1084.         /// 取属相字符串 
  1085.         /// </summary> 
  1086.         public string AnimalString 
  1087.         { 
  1088.             get 
  1089.             { 
  1090.                 int offset = _date.Year - AnimalStartYear; 
  1091.                 return animalStr[offset % 12].ToString(); 
  1092.             } 
  1093.         } 
  1094.         #endregion 
  1095.         #endregion 
  1096.  
  1097.         #region 天干地支 
  1098.         #region GanZhiYearString 
  1099.         /// <summary> 
  1100.         /// 取农历年的干支表示法如 乙丑年 
  1101.         /// </summary> 
  1102.         public string GanZhiYearString 
  1103.         { 
  1104.             get 
  1105.             { 
  1106.                 string tempStr; 
  1107.                 int i=(this._cYear - GanZhiStartYear) % 60; //计算干支 
  1108.                 tempStr = ganStr[i % 10].ToString() + zhiStr[i % 12].ToString() + "年"
  1109.                 return tempStr; 
  1110.             } 
  1111.         } 
  1112.         #endregion 
  1113.  
  1114.         #region GanZhiMonthString 
  1115.         /// <summary> 
  1116.         /// 取干支的月表示字符串,注意农历的闰月不记干支 
  1117.         /// </summary> 
  1118.         public string GanZhiMonthString 
  1119.         { 
  1120.             get 
  1121.             { 
  1122.                 //每个月的地支总是固定的,而且总是从寅月开始 
  1123.                 int zhiIndex; 
  1124.                 string zhi; 
  1125.                 if (this._cMonth > 10) 
  1126.                 { 
  1127.                     zhiIndex = this._cMonth - 10; 
  1128.                 } 
  1129.                 else 
  1130.                 { 
  1131.                     zhiIndex = this._cMonth + 2; 
  1132.                 } 
  1133.                 zhi = zhiStr[zhiIndex - 1].ToString(); 
  1134.  
  1135.                 //根据当年的干支年的干来计算月干的第一个 
  1136.                 int ganIndex=1; 
  1137.                 string gan; 
  1138.                 int i = (this._cYear - GanZhiStartYear) % 60; //计算干支 
  1139.                 switch (i%10) 
  1140.                 { 
  1141.                     #region ... 
  1142.                     case 0: //甲 
  1143.                         ganIndex = 3; 
  1144.                         break
  1145.                     case 1: //乙 
  1146.                         ganIndex = 5; 
  1147.                         break
  1148.                     case 2: //丙 
  1149.                         ganIndex = 7; 
  1150.                         break
  1151.                     case 3: //丁 
  1152.                         ganIndex = 9; 
  1153.                         break
  1154.                     case 4: //戊 
  1155.                         ganIndex = 1; 
  1156.                         break
  1157.                     case 5: //己 
  1158.                         ganIndex = 3; 
  1159.                         break
  1160.                     case 6: //庚 
  1161.                         ganIndex = 5; 
  1162.                         break
  1163.                     case 7: //辛 
  1164.                         ganIndex = 7; 
  1165.                         break
  1166.                     case 8: //壬 
  1167.                         ganIndex = 9; 
  1168.                         break
  1169.                     case 9: //癸 
  1170.                         ganIndex = 1; 
  1171.                         break
  1172.                     #endregion 
  1173.                 } 
  1174.                 gan = ganStr[(ganIndex + this._cMonth -2) % 10].ToString(); 
  1175.  
  1176.                 return gan + zhi + "月"
  1177.             } 
  1178.         } 
  1179.         #endregion 
  1180.  
  1181.         #region GanZhiDayString 
  1182.         /// <summary> 
  1183.         /// 取干支日表示法 
  1184.         /// </summary> 
  1185.         public string GanZhiDayString 
  1186.         { 
  1187.             get 
  1188.             { 
  1189.                 int i,offset; 
  1190.                 TimeSpan ts = this._date - GanZhiStartDay; 
  1191.                 offset = ts.Days; 
  1192.                 i = offset % 60; 
  1193.                 return ganStr[i % 10].ToString() + zhiStr[i % 12].ToString() + "日"
  1194.             } 
  1195.         } 
  1196.         #endregion 
  1197.  
  1198.         #region GanZhiDateString 
  1199.         /// <summary> 
  1200.         /// 取当前日期的干支表示法如 甲子年乙丑月丙庚日 
  1201.         /// </summary> 
  1202.         public string GanZhiDateString 
  1203.         { 
  1204.             get 
  1205.             { 
  1206.                 return GanZhiYearString + GanZhiMonthString + GanZhiDayString; 
  1207.             } 
  1208.         } 
  1209.         #endregion 
  1210.         #endregion 
  1211.         #endregion 
  1212.  
  1213.         #region 方法 
  1214.         #region NextDay 
  1215.         /// <summary> 
  1216.         /// 取下一天 
  1217.         /// </summary> 
  1218.         /// <returns></returns> 
  1219.         public ChineseCalendar NextDay() 
  1220.         { 
  1221.             DateTime nextDay = _date.AddDays(1); 
  1222.             return new ChineseCalendar(nextDay); 
  1223.         } 
  1224.         #endregion 
  1225.  
  1226.         #region PervDay 
  1227.         /// <summary> 
  1228.         /// 取前一天 
  1229.         /// </summary> 
  1230.         /// <returns></returns> 
  1231.         public ChineseCalendar PervDay() 
  1232.         { 
  1233.             DateTime pervDay = _date.AddDays(-1); 
  1234.             return new ChineseCalendar(pervDay); 
  1235.         } 
  1236.         #endregion 
  1237.         #endregion 
  1238.     } 

 

被阅809次, 0投一票
  • 看完了要说点啥么?
  • 昵称 (不填说不了话)
  • 信箱地址 (不会被公开,但是不填也说不了话)
  • 网址 (这个不填也成)

Powered by MiniBoke v2.0.0.8 Build 0828

Copyright © 2008 迷你博客. All rights reserved.

粤ICP备07500939号