是2.0的,沒有試驗過,先保留著,以后還有用
以下是代碼片段:
using system;
using system.collections.generic;
using system.globalization;
namespace chineselunisolarcalendar
{
 class chinesealmanac : system.globalization.chineselunisolarcalendar
 {
  private system.globalization.chineselunisolarcalendar netcalendar = new system.globalization.chineselunisolarcalendar();
#region 加強
  /// <summary>
  /// 獲取該農歷對象的屬相。
  /// </summary>
  /// <returns>0-11,如“鼠”為0</returns>
  public string getanimalsign(datetime solardatetime)
  {
   return "豬鼠牛虎兔龍蛇馬羊猴雞狗".substring(zhi(getchineseeraofyear(solardatetime)), 1);
  }
  /// <summary>
  /// 獲取年柱。
  /// </summary>
  public int getchineseeraofyear(datetime solardatetime)
  {
   int g = (solardatetime.year - 1900 + 36) % 60;
   if ((daydifference(solardatetime.year, solardatetime.month, solardatetime.day) + solardatetime.hour / 24) < term(solardatetime.year, 3, true) - 1)
   {//判斷是否過立春
    g -= 1;
   }
   return g + 1;
  }
  /// <summary>
  /// 獲取月柱。
  /// </summary>
  public int getchineseeraofmonth(datetime solardatetime)
  {
   int v = ((solardatetime.year - 1900) * 12 + solardatetime.month + 12) % 60;
   if (solardatetime.day <= getsolarterm(solardatetime)[0].solartermdatetime.day)
    v -= 1;
   return v + 1;
  }
  /// <summary>
  /// 獲取日柱。
  /// </summary>
  public int getchineseeraofday(datetime solardatetime)
  {
   double gzd = (solardatetime.hour < 23) ? equivalentstandardday(solardatetime.year, solardatetime.month, solardatetime.day) : equivalentstandardday(solardatetime.year, solardatetime.month, solardatetime.day) + 1;
   return (int) math.round((double) rem((int) gzd + 15, 60));
  }
  /// <summary>
  /// 獲取時柱。
  /// </summary>
  public int getchineseeraofhour(datetime solardatetime)
  {
   double v = 12 * gan(getchineseeraofday(solardatetime)) + system.math.floor((double) ((solardatetime.hour + 1) / 2)) - 11;
   if (solardatetime.hour == 23)
    v -= 12;
   return (int) math.round(rem(v, 60));
  }
  /// <summary>
  /// 獲取指定日期的節氣。
  /// </summary>
  /// <param name="year">要獲取的年</param>
  /// <param name="month">要獲取的月</param>
  /// <returns></returns>
  /// <remarks>
  /// 立春:立是開始的意思,春是蠢動,表示萬物開始有生氣,這一天春天開始。
  /// 雨水:降雨開始,雨水將多。
  /// 驚蟄:春雷響動,驚動蟄伏地下冬眠的生物,它們將開始出土活動。
  /// 春分:這是春季九十天的中分點,這一天晝夜相等,所以古代曾稱春分秋分為晝夜分。
  /// 清明:明潔晴朗,氣候溫暖,草木開始萌發繁茂。
  /// 谷雨:雨生百谷的意思。雨水增多,適時的降雨對谷物生長很為有利。
  /// 立夏:夏天開始,萬物漸將隨溫暖的氣候而生長。
  /// 小滿:滿指籽粒飽滿,麥類等夏熱作物這時開始結籽灌漿,即將飽滿。
  /// 芒種:有芒作物開始成熟,此時也是秋季作物播種的最繁忙時節。
  /// 夏至:白天最長,黑夜最短,這一天中午太陽位置最高,日影短至終極,古代又稱這一天為日北至或長日至。
  /// 小暑:暑是炎熱,此時還未到達最熱。
  /// 大暑:炎熱的程度到達高峰。
  /// 立秋:秋天開始,植物快成熟了。
  /// 處暑:處是住的意思,表示暑氣到此為止。
  /// 白露:地面水氣凝結為露,色白,是天氣開始轉涼了。
  /// 秋分:秋季九十天的中間,這一天晝夜相等,同春分一樣,太陽從正東升起正西落下。
  /// 寒露:水露先白而后寒,是氣候將逐漸轉冷的意思。
  /// 霜降:水氣開始凝結成霜。
  /// 立冬:冬是終了,作物收割后要收藏起來的意思,這一天起冬天開始。
  /// 小雪:開始降雪,但還不多。
  /// 大雪:雪量由小增大。
  /// 冬至:這一天中午太陽在天空中位置最低,日影最長,白天最短, 黑夜最長,古代又稱短日至或日南至。
  /// 小寒:冷氣積久而為寒,此時尚未冷到頂點。
  /// 大寒:天候達到最寒冷的程度
  /// </remarks>
  public solarterm[] getsolarterm(int year, int month)
  {
   string[] lunarholidayname ={ 
            "小寒", "大寒", "立春", "雨水","驚蟄", "春分", "清明", "谷雨","立夏", "小滿", "芒種", "夏至", 
            "小暑", "大暑", "立秋", "處暑","白露", "秋分", "寒露", "霜降","立冬", "小雪", "大雪", "冬至"};
   solarterm[] solarterm = new solarterm[2];
   for (int n = month * 2 - 1 ; n <= month * 2 ; n++)
   {
    solarterm st = new solarterm();
    double dd = term(year, n, true);
    double sd1 = antidaydifference(2005, math.floor(dd));
    double sm1 = math.floor(sd1 / 100);
    int h = (int) math.floor((double) tail(dd) * 24);
    int min = (int) math.floor((double) (tail(dd) * 24 - h) * 60);
    int mmonth = (int) math.ceiling((double) n / 2);
    int day = (int) sd1 % 100;
    st.solartermdatetime = new datetime(year, mmonth, day, h, min, 0);
    st.name = lunarholidayname[n - 1];
    solarterm[n - month * 2 + 1] = st;
   }
   return solarterm;
  }
  /// <summary>
  /// 獲取指定日期的節氣。
  /// </summary>
  /// <param name="solardatetime"></param>
  /// <returns></returns>
  /// <remarks>我國農歷里把節氣分得很細,定出了二十四節氣,它們的名稱大都反應物候、農時或季節的起點與中點。由于節氣實際反應太陽運行所引 起的氣候變化,故二十四節氣為陽歷的自然衍生的產物,與陰歷無關。二十四節氣中以立春、春分、立夏,夏至、立秋、秋分、立冬與冬至等八節氣最為重要。它們之間大約相隔46天。一年分為四季,「立」表示四季中每一個季節的開始,而「分」與「至」表示正處于這季節的中間。現代我國所使用的歷法,皆依回歸年制定,二十四節氣基本上是一致的,前后的相差不會超過一兩天。為了調合回歸年(陽歷)與朔望月(陰歷)之間的差異,農歷把二十四節氣中,雙數的叫中氣,單數的叫節氣,而且規定每一個中氣標定在一個農歷的月份,例如雨水必定在正月,春分必定在二月,谷雨必定在三月,其余依此類推。另外,月名也必須和相對應的中氣相合。</remarks>
  public solarterm[] getsolarterm(datetime solardatetime)
  {
   return getsolarterm(solardatetime.year, solardatetime.month);
  }
  /// <summary>
  /// 返回星座
  /// </summary>
  public string getconstellation(datetime solardatetime)
  {
   int constellation = -1;
   int y = solardatetime.month * 100 + solardatetime.day;
   if (((y >= 321) && (y <= 419))) { constellation = 0; }
   else if ((y >= 420) && (y <= 520)) { constellation = 1; }
   else if ((y >= 521) && (y <= 620)) { constellation = 2; }
   else if ((y >= 621) && (y <= 722)) { constellation = 3; }
   else if ((y >= 723) && (y <= 822)) { constellation = 4; }
   else if ((y >= 823) && (y <= 922)) { constellation = 5; }
   else if ((y >= 923) && (y <= 1022)) { constellation = 6; }
   else if ((y >= 1023) && (y <= 1121)) { constellation = 7; }
   else if ((y >= 1122) && (y <= 1221)) { constellation = 8; }
   else if ((y >= 1222) || (y <= 119)) { constellation = 9; }
   else if ((y >= 120) && (y <= 218)) { constellation = 10; }
   else if ((y >= 219) && (y <= 320)) { constellation = 11; }
   string con = "白羊金牛雙子巨蟹獅子處女天秤天蝎射手摩羯水瓶雙魚";
   return con.substring(2 * constellation, 2) + "座";
  }
  /// <summary>
  /// 獲取儒略日。
  /// </summary>
  /// <remarks>zone時區y年m月d日h時min分sec秒距儒略歷公元前4713年1月1日格林尼治時間正午12時的天數</remarks>
  public double getjulianday(datetime solardatetime)
  {
   int ifg = ifgregorian(solardatetime.year, solardatetime.month, solardatetime.day, 1);
   double jt = (solardatetime.hour + (solardatetime.minute + solardatetime.second / 60) / 60) / 24 - 0.5 - timezone.currenttimezone.getutcoffset(solardatetime).hours / 24;
   double jd = (ifg == 1) ? (equivalentstandardday(solardatetime.year, solardatetime.month, solardatetime.day) + 1721425 + jt) : (equivalentstandardday(solardatetime.year, solardatetime.month, solardatetime.day) + 1721425 + jt);//儒略日
   return jd;
  }
  /// <summary>
  /// 獲取約化儒略日。
  /// </summary>
  /// <remarks>為了使用方便,國際上定義當前儒略日減去2400000.5日為約化儒略日(記為mjd)。</remarks>
  public double getminijulianday(datetime solardatetime)
  {
   return getjulianday(solardatetime) - 2400000.5;
  }
  /// <summary>
  /// 獲取該農歷日日食月食情況。
  /// </summary>
  /// <returns>eclipse對象,包含該農歷日日食月食情況。</returns>
  public eclipse geteclipse(datetime solardatetime, double timezone)
  {
   eclipse re = new eclipse();
   double t = (solardatetime.year - 1899.5) / 100;
   double ms = math.floor((solardatetime.year - 1900) * 12.3685);
   double rpi = 180 / math.pi;
   double zone = timezone;  //時區
   double f0 = angle(ms, t, 0, 0.75933, 2.172e-4, 1.55e-7) + 0.53058868 * ms - 8.37e-4 * t + zone / 24 + 0.5;
   double fc = 0.1734 - 3.93e-4 * t;
   double j0 = 693595 + 29 * ms;
   double aa0 = angle(ms, t, 0.08084821133, 359.2242 / rpi, 0.0000333 / rpi, 0.00000347 / rpi);
   double ab0 = angle(ms, t, 7.171366127999999e-2, 306.0253 / rpi, -0.0107306 / rpi, -0.00001236 / rpi);
   double ac0 = angle(ms, t, 0.08519585128, 21.2964 / rpi, 0.0016528 / rpi, 0.00000239 / rpi);
   //double leap=0;  //閏月數,0則不閏
   double lund = -1;  //農歷日數
   //double shuod=0;  //本陰歷月的陰歷朔日數
   double shuot = 0;  //本陰歷月的朔時刻
   double wangd = 0;  //本陰歷月的望時刻
   double wangt = 0;  //本陰歷月的陰歷望日數
   double k1 = 0;
   for (double k = -1 ; k <= 13 ; k += 0.5)
   {  //k=整數為朔,k=半整數為望
    double aa = aa0 + 0.507984293 * k;
    double ab = ab0 + 6.73377553 * k;
    double ac = ac0 + 6.818486628 * k;
    double f1 = f0 + 1.53058868 * k + fc * math.sin(aa) - 0.4068 * math.sin(ab) + 0.0021 * math.sin(2 * aa) + 0.0161 * math.sin(2 * ab) + 0.0104 * math.sin(2 * ac) - 0.0074 * math.sin(aa - ab) - 0.0051 * math.sin(aa + ab);
    double j = j0 + 28 * k + f1;  //朔或望的等效標準天數及時刻
    //記錄當前日期的j值 
    double lund0 = equivalentstandardday(solardatetime.year, solardatetime.month, solardatetime.day) - math.floor(j);  //當前日距朔日的差值
    if (k == math.floor(k) && lund0 >= 0 && lund0 <= 29)
    {
     k1 = k;  //記錄當前時間對應的k值
     shuot = tail(j);
     lund = lund0 + 1;
    }
    if (k == (k1 + 0.5))
    {
     wangt = tail(j);
     wangd = math.floor(j) - (equivalentstandardday(solardatetime.year, solardatetime.month, solardatetime.day) - lund + 1) + 1;
    }
    //判斷日月食
    re.phenomena = eclipsephenomena.none;
    if ((lund == 1 && k == k1) || (lund == wangd && k == (k1 + 0.5)))
    {
     if (math.abs(math.sin(ac)) <= 0.36)
     {
      double s = 5.19595 - 0.0048 * math.cos(aa) + 0.002 * math.cos(2 * aa) - 0.3283 * math.cos(ab) - 0.006 * math.cos(aa + ab) + 0.0041 * math.cos(aa - ab);
      double r = 0.207 * math.sin(aa) + 0.0024 * math.sin(2 * aa) - 0.039 * math.sin(ab) + 0.0115 * math.sin(2 * ab) - 0.0073 * math.sin(aa + ab) - 0.0067 * math.sin(aa - ab) + 0.0117 * math.sin(2 * ac);
      double p = math.abs(s * math.sin(ac) + r * math.cos(ac));
      double q = 0.0059 + 0.0046 * math.cos(aa) - 0.0182 * math.cos(ab) + 0.0004 * math.cos(2 * ab) - 0.0005 * math.cos(aa + ab);
      if (p - q <= 1.5572)
      {
       re.phenomena = eclipsephenomena.eclipseofsun;  //日食
       if (k != math.floor(k))
       {
        if (p + q >= 1.0129)
         re.phenomena = eclipsephenomena.partialeclipseofthemoon;  //月偏食
        else
         re.phenomena = eclipsephenomena.completeeclipseofthemoon;  //月全食
       }
      }
     }
    }
   }
   //k循環結束
   re.syzygy = syzygy.none;
   if (lund == 1)
   {
    re.syzygy = syzygy.newmoon;
    int h = (int) math.floor(shuot * 24);
    int min = (int) math.floor((shuot * 24 - h) * 60);
    re.datetime = new datetime(solardatetime.year, solardatetime.month, solardatetime.day, h, min, 0);  //朔日則返回朔的時刻
   }
   if (lund == wangd)
   {
    re.syzygy = syzygy.fullmoon;
    int h = (int) math.floor(wangt * 24);
    int min = (int) math.floor((wangt * 24 - h) * 60);
    re.datetime = new datetime(solardatetime.year, solardatetime.month, solardatetime.day, h, min, 0);  //望日則返回望的時刻
   }
   return re;
  }
#endregion
#region 字符串相關
  /// <summary>
  /// 返回甲子數x對應的天干字符串
  /// </summary>
  public string tostringwithcelestialstem(int x)
  {
   return "癸甲乙丙丁戊己庚辛壬".substring(x % 10, 1);
  }
  /// <summary>
  /// 返回甲子數x對應的地支字符串
  /// </summary>
  public string tostringwithterrestrialbranch(int x)
  {
   return "亥子丑寅卯辰巳午未申酉戌".substring(x % 12, 1);
  }
  /// <summary>
  /// 返回甲子數x對應的干支字符串
  /// </summary>
  /// <param name="x"></param>
  /// <returns></returns>
  public string tostringwithsexagenary(int x)
  {
   return tostringwithcelestialstem(x) + tostringwithterrestrialbranch(x);
  }
  /// <summary>
  /// 將返回農歷日對應的字符串
  /// </summary>
  /// <param name="v"></param>
  /// <returns></returns>
  public string tostringwithchineseday(int v)
  {
   string str = "十一二三四五六七八九初十廿三";
   string vstr = str.substring((int) math.floor((double) v / 10) + 10, 1) + str.substring((int) v % 10, 1);
   if (v == 10)
    vstr = "初十";
   return vstr;
  }
  /// <summary>
  /// 獲取指定數的納音五行。
  /// </summary>
  /// <param name="x"></param>
  /// <returns></returns>
  /// <remarks>六十甲子和五音十二律結合起來,其中一律含五音,總數共為六十的“納音五行”。</remarks>
  public string getnayinwuxing(int x)
  {
   string[] s = new string[]
    { "海中金", "爐中火", "大林木", "路旁土", "劍鋒金", "山頭火", "洞下水", "城墻土", "白臘金", "楊柳木", "泉中水", 
    "屋上土", "霹雷火", "松柏木", "常流水", "沙中金", "山下火", "平地木", "壁上土", "金箔金", "佛燈火", "天河水", 
    "大驛土", "釵釧金", "桑松木", "大溪水", "沙中土", "天上火", "石榴木", "大海水" };
   return s[(int) math.floor((double) ((x - 1) / 2))];
  }
  /// <summary>
  /// 獲取指定時間的月代名詞。
  /// </summary>
  /// <param name="solardatetime">要獲取的陽歷對象</param>
  /// <returns></returns>
  /// <remarks>一年分為春夏秋冬四時,后來又按夏歷正月、二月、三月等十二個月分為孟春、仲春、季春、孟夏、仲夏、季夏、孟秋、仲秋、季秋、孟冬、仲冬、季冬。古書常把這些名稱作為月份的代名詞。</remarks>
  public string getchinesemonthpronoun(datetime solardatetime)
  {
   string[] s = new string[] { "孟春", "仲春", "季春", "孟夏", "仲夏", "季夏", "孟秋", "仲秋", "季秋", "孟冬", "仲冬", "季冬" };
   return s[netcalendar.getmonth(solardatetime) - 1];
  }
  /// <summary>
  /// 獲取指定時間的七十二候。
  /// </summary>
  /// <remarks>五天一候,一年365天(平年)為73候,為與24節氣對應,規定三候為一節(氣)、一年為72候。每一候均以一種物候現象作相應,叫“候應”。72候的“候”應包括非生物和生物兩大類,前者如“水始涸”、“東風解凍”、“虹始見”、“地始凍”等;后者有動物和植物,如“鴻雁來”、“虎始交”、“萍始生”、“苦菜秀”、“桃始華”等。七十二候的起源很早,對農事活動曾起過一定作用。雖然其中有些物候描述不那么準確,其中還有不科學成份,但對于了解古代華北地區的氣候及其變遷,仍然具有一定的參考價值。由于當時確定物候的始見單位較小而氣候的實際及地區差別很大,所以很難廣泛應用。現在黃河流域物候現象已發生變化,其他地區的物候更是千差萬別,必須不斷發展物候學,制定新的自然歷,否則一味地機械照搬古書是行不通的。</remarks>
  /// <param name="solardatetime">要獲取的陽歷對象</param>
  /// <returns></returns>
  public string getwuhou(datetime solardatetime)
  {
   string xs1 = string.empty;
   solarterm[] solar = getsolarterm(solardatetime);
   int jq = solar[0].solartermdatetime.day;
   int zq = solar[1].solartermdatetime.day;
   int c = solardatetime.day + 1;
   int month = solardatetime.month - 1;
   if (month == 0)
   {
    if (c < jq - 1) { xs1 = "水泉動"; }
    else if (c >= jq - 1 && c <= jq + 3) { xs1 = "雁北鄉"; }
    else if (c > jq + 3 && c <= jq + 8) { xs1 = "鵲始巢"; }
    else if (c > jq + 8 && c < zq - 1) { xs1 = "鳺始鴝"; }
    else if (c >= zq - 1 && c <= zq + 3) { xs1 = "雞始乳"; }
    else if (c > zq + 3 && c <= zq + 8) { xs1 = "征鳥厲疾"; }
    else if (c > zq + 8) { xs1 = "水澤腹堅"; }
   }
   if (month == 1)
   {
    if (c < jq - 1) { xs1 = "水澤腹堅"; }
    else if (c >= jq - 1 && c <= jq + 3) { xs1 = "東風解凍"; }
    else if (c > jq + 3 && c <= jq + 8) { xs1 = "蟄蟲始振"; }
    else if (c > jq + 8 && c < zq - 1) { xs1 = "魚上冰"; }
    else if (c >= zq - 1 && c <= zq + 3) { xs1 = "獺祭魚"; }
    else if (c > zq + 3 && c <= zq + 8) { xs1 = "候雁北"; }
    else if (c > zq + 8) { xs1 = "草木萌動"; }
   }
   if (month == 2)
   {
    if (c < jq - 1) { xs1 = "草木萌動"; }
    else if (c >= jq - 1 && c <= jq + 3) { xs1 = "桃始華"; }
    else if (c > jq + 3 && c <= jq + 8) { xs1 = "倉庚鳴"; }
    else if (c > jq + 8 && c < zq - 1) { xs1 = "鷹化為鳩"; }
    else if (c >= zq - 1 && c <= zq + 3) { xs1 = "玄鳥至"; }
    else if (c > zq + 3 && c <= zq + 8) { xs1 = "雷乃發聲"; }
    else if (c > zq + 8) { xs1 = "始電"; }
   }
   if (month == 3)
   {
    if (c < jq - 1) { xs1 = "始電"; }
    else if (c >= jq - 1 && c <= jq + 3) { xs1 = "桐始華"; }
    else if (c > jq + 3 && c <= jq + 8) { xs1 = "田鼠化為鴽"; }
    else if (c > jq + 8 && c < zq - 1) { xs1 = "虹始見"; }
    else if (c >= zq - 1 && c <= zq + 3) { xs1 = "萍始生"; }
    else if (c > zq + 3 && c <= zq + 8) { xs1 = "鳴鳩拂其羽"; }
    else if (c > zq + 8) { xs1 = "戴勝降于桑"; }
   }
   if (month == 4)
   {
    if (c < jq - 1) { xs1 = "戴勝降于桑"; }
    else if (c >= jq - 1 && c <= jq + 3) { xs1 = "螻蟈鳴"; }
    else if (c > jq + 3 && c <= jq + 8) { xs1 = "蚯蚓出"; }
    else if (c > jq + 8 && c < zq - 1) { xs1 = "王瓜生"; }
    else if (c >= zq - 1 && c <= zq + 3) { xs1 = "苦菜秀"; }
    else if (c > zq + 3 && c <= zq + 8) { xs1 = "靡草死"; }
    else if (c > zq + 8) { xs1 = "麥秋至"; }
   }
   if (month == 5)
   {
    if (c < jq - 1) { xs1 = "麥秋至"; }
    else if (c >= jq - 1 && c <= jq + 3) { xs1 = "螳螂生"; }
    else if (c > jq + 3 && c <= jq + 8) { xs1 = "鵙始鳴"; }
    else if (c > jq + 8 && c < zq - 1) { xs1 = "反舌無聲"; }
    else if (c >= zq - 1 && c <= zq + 3) { xs1 = "鹿角解"; }
    else if (c > zq + 3 && c <= zq + 8) { xs1 = "蜩始鳴"; }
    else if (c > zq + 8) { xs1 = "半夏生"; }
   }
   if (month == 6)
   {
    if (c < jq - 1) { xs1 = "半夏生"; }
    else if (c >= jq - 1 && c <= jq + 3) { xs1 = "溫風至"; }
    else if (c > jq + 3 && c <= jq + 8) { xs1 = "蟀蟋居壁"; }
    else if (c > jq + 8 && c < zq - 1) { xs1 = "鷹如鷙"; }
    else if (c >= zq - 1 && c <= zq + 3) { xs1 = "腐草為螢"; }
    else if (c > zq + 3 && c <= zq + 8) { xs1 = "土潤溽暑"; }
    else if (c > zq + 8) { xs1 = "大雨時行"; }
   }
   if (month == 7)
   {
    if (c < jq - 1) { xs1 = "大雨時行"; }
    else if (c >= jq - 1 && c <= jq + 3) { xs1 = "涼風至"; }
    else if (c > jq + 3 && c <= jq + 8) { xs1 = "白露降"; }
    else if (c > jq + 8 && c < zq - 1) { xs1 = "寒蟬鳴"; }
    else if (c >= zq - 1 && c <= zq + 3) { xs1 = "鷹乃祭鳥"; }
    else if (c > zq + 3 && c <= zq + 8) { xs1 = "天地始肅"; }
    else if (c > zq + 8) { xs1 = "禾乃登"; }
   }
   if (month == 8)
   {
    if (c < jq - 1) { xs1 = "禾乃登"; }
    else if (c >= jq - 1 && c <= jq + 3) { xs1 = "鴻雁來"; }
    else if (c > jq + 3 && c <= jq + 8) { xs1 = "玄鳥歸"; }
    else if (c > jq + 8 && c < zq - 1) { xs1 = "群鳥養羞"; }
    else if (c >= zq - 1 && c <= zq + 3) { xs1 = "雷乃收聲"; }
    else if (c > zq + 3 && c <= zq + 8) { xs1 = "蟄蟲坯戶"; }
    else if (c > zq + 8) { xs1 = "水始涸"; }
   }
   if (month == 9)
   {
    if (c < jq - 1) { xs1 = "水始涸"; }
    else if (c >= jq - 1 && c <= jq + 3) { xs1 = "鴻雁來賓"; }
    else if (c > jq + 3 && c <= jq + 8) { xs1 = "雀入大水為蛤"; }
    else if (c > jq + 8 && c < zq - 1) { xs1 = "菊有黃花"; }
    else if (c >= zq - 1 && c <= zq + 3) { xs1 = "豺乃祭獸"; }
    else if (c > zq + 3 && c <= zq + 8) { xs1 = "草木黃落"; }
    else if (c > zq + 8) { xs1 = "蟄蟲咸俯"; }
   }
   if (month == 10)
   {
    if (c < jq - 1) { xs1 = "蟄蟲咸俯"; }
    else if (c >= jq - 1 && c <= jq + 3) { xs1 = "水始冰"; }
    else if (c > jq + 3 && c <= jq + 8) { xs1 = "地始凍"; }
    else if (c > jq + 8 && c < zq - 1) { xs1 = "雉入大水為蜃"; }
    else if (c >= zq - 1 && c <= zq + 3) { xs1 = "虹藏不見"; }
    else if (c > zq + 3 && c <= zq + 8) { xs1 = "天氣騰地氣降"; }
    else if (c > zq + 8) { xs1 = "閉塞成冬"; }
   }
   if (month == 11)
   {
    if (c < jq - 1) { xs1 = "閉塞成冬"; }
    else if (c >= jq - 1 && c <= jq + 3) { xs1 = "鹖鴠不鳴"; }
    else if (c > jq + 3 && c <= jq + 8) { xs1 = "虎始交"; }
    else if (c > jq + 8 && c < zq - 1) { xs1 = "荔挺出"; }
    else if (c >= zq - 1 && c <= zq + 3) { xs1 = "蚯蚓結"; }
    else if (c > zq + 3 && c <= zq + 8) { xs1 = "麋鹿解"; }
    else if (c > zq + 8) { xs1 = "水泉動"; }
   }
   return xs1;
  }
  /// <summary>
  /// 獲取當日月相名。
  /// </summary>
  /// <param name="solardatetime">要獲取的陽歷對象</param>
  /// <returns></returns>
  public string getmoonname(datetime solardatetime)
  {
   string mnname = string.empty;
   int month = netcalendar.getdayofmonth(solardatetime);
   if (month >= 24) mnname = "有明月";
   if (month <= 14) mnname = "宵月";
   if (month <= 7) mnname = "夕月";
   if (month == 1) mnname = "新(朔)月";
   if (month == 2) mnname = "既朔月";
   if (month == 3) mnname = "娥眉新月";
   if (month == 4) mnname = "娥眉新月";
   if (month == 5) mnname = "娥眉月";
   if (month == 7) mnname = "上弦月";
   if (month == 8) mnname = "上弦月";
   if (month == 9) mnname = "九夜月";
   if (month == 13) mnname = "漸盈凸月";
   if (month == 14) mnname = "小望月";
   if (month == 15) mnname = "滿(望)月";
   if (month == 16) mnname = "既望月";
   if (month == 17) mnname = "立待月";
   if (month == 18) mnname = "居待月";
   if (month == 19) mnname = "寢待月";
   if (month == 20) mnname = "更待月";
   if (month == 21) mnname = "漸虧凸月";
   if (month == 22) mnname = "下弦月";
   if (month == 23) mnname = "下弦月";
   if (month == 26) mnname = "娥眉殘月";
   if (month == 27) mnname = "娥眉殘月";
   if (month == 28) mnname = "殘月";
   if (month == 29) mnname = "曉月";
   if (month == 30) mnname = "晦月";
   return mnname;
  }
  /// <summary>
  /// 獲取指定時間的日祿。
  /// </summary>
  /// <param name="solardatetime">要獲取的陽歷對象</param>
  /// <returns></returns>
  public string getrilu(datetime solardatetime)
  {
   string dayglk = "寅卯巳午巳午申酉亥子";
   int bsg = zhi(ld(solardatetime));
   int bs = gan(ld(solardatetime));
   string dayglus = string.empty;
   if (bsg == 0) { dayglus = tostringwithcelestialstem(10) + "命進祿"; }
   else if (bsg == 2) { dayglus = tostringwithcelestialstem(1) + "命進祿"; }
   else if (bsg == 3) { dayglus = tostringwithcelestialstem(2) + "命進祿"; }
   else if (bsg == 5) { dayglus = tostringwithcelestialstem(3) + "," + tostringwithcelestialstem(5) + "命進祿"; }
   else if (bsg == 6) { dayglus = tostringwithcelestialstem(4) + "," + tostringwithcelestialstem(6) + "命進祿"; }
   else if (bsg == 8) { dayglus = tostringwithcelestialstem(7) + "命進祿"; }
   else if (bsg == 9) { dayglus = tostringwithcelestialstem(8) + "命進祿"; }
   else if (bsg == 11) { dayglus = tostringwithcelestialstem(9) + "命進祿"; }
   else { dayglus = ""; }
   return dayglk.substring(bs, 1) + "命互祿 " + dayglus;
  }
  /// <summary>
  /// 獲取吉神方位。
  /// </summary>
  /// <param name="solardatetime"></param>
  /// <returns></returns>
  public string getluckydeity(datetime solardatetime)
  {
   int bs = gan(ld(solardatetime));
string xs = string.empty, fs = string.empty, cs = string.empty;
   if (bs == 0 || bs == 5) { xs = "喜神:東北 "; }
   else if (bs == 1 || bs == 6) { xs = "喜神:西北 "; }
   else if (bs == 2 || bs == 7) { xs = "喜神:西南 "; }
   else if (bs == 3 || bs == 8) { xs = "喜神:正南 "; }
   else if (bs == 4 || bs == 9) { xs = "喜神:東南 "; }
   if (bs == 0 || bs == 1) { fs = "福神:東南 "; }
   else if (bs == 2 || bs == 3) { fs = "福神:正東 "; }
   else if (bs == 4) { fs = "福神:正北 "; }
   else if (bs == 5) { fs = "福神:正南 "; }
   else if (bs == 6 || bs == 7) { fs = "福神:西南 "; }
   else if (bs == 8) { fs = "福神:西北 "; }
   else if (bs == 9) { fs = "福神:正西 "; }
   if (bs == 0 || bs == 1) { cs = "財神:東北"; }
   else if (bs == 2 || bs == 3) { cs = "財神:西南"; }
   else if (bs == 4 || bs == 5) { cs = "財神:正北"; }
   else if (bs == 6 || bs == 7) { cs = "財神:正東"; }
   else if (bs == 8 || bs == 9) { cs = "財神:正南"; }
   return xs + fs + cs;
  }
  /// <summary>
  /// 獲取彭祖百忌。
  /// </summary>
  /// <param name="solardatetime"></param>
  /// <returns></returns>
  /// <remarks>每日時辰應忌諱之事</remarks>
  public string getpengzubaiji(datetime solardatetime)
  {
   string[] g = new string[] { "甲不開倉 ", "乙不栽植 ", "丙不修灶 ", "丁不剃頭 ", "戊不受田 ", "己不破券 ", "庚不經絡 ", "辛不合醬 ", "壬不泱水 ", "癸不詞訟 " };
   string[] z = new string[] { "子不問卜", "丑不冠帶", "寅不祭祀", "卯不穿井", "辰不哭泣", "巳不遠行", "午不苫蓋", "未不服藥", "申不安床", "酉不會客", "戌不吃犬", "亥不嫁娶" };
   int ceod = getchineseeraofday(solardatetime) - 1;
   return g[ceod % 10] + z[ceod % 12];
  }
  /// <summary>
  /// 獲取相沖。
  /// </summary>
  /// <param name="solardatetime"></param>
  /// <returns></returns>
  /// <remarks>“沖”即地支相沖,即子午相沖、丑未相沖、寅申相沖、卯酉相沖、辰戌相沖、巳亥相沖,再把十二地支配以十二屬相,子鼠、丑牛、寅虎、卯兔、辰龍、巳蛇、午馬、未羊、申猴、酉雞、戌狗、亥豬。于是,凡子日,與午相沖,即為“沖馬”;寅日,與申相沖,即為“沖猴”。黃歷設立此款,是告訴人們,不要選用那些與自己屬相相沖的日子。</remarks>
  public string getxiangchong(datetime solardatetime)
  {
   string[] gan = new string[] { "戊", "己", "庚", "辛", "壬", "癸", "甲", "乙", "丙", "丁" };
   string[] zhi = new string[] { "午", "未", "申", "酉", "戌", "亥", "子", "丑", "寅", "卯", "辰", "巳" };
   string[] animal = new string[] { "鼠", "牛", "虎", "兔", "龍", "蛇", "馬", "羊", "猴", "雞", "狗", "豬" };
   string[] animal2 = new string[] { "馬", "羊", "猴", "雞", "狗", "豬", "鼠", "牛", "虎", "兔", "龍", "蛇" };
   int dd = zhi(ld(solardatetime));
   int d = gan(ld(solardatetime));
   return animal[dd] + "日沖(" + gan[d] + zhi[dd] + ")" + animal2[dd];
  }
  /// <summary>
  /// 獲取歲煞。
  /// </summary>
  /// <param name="solardatetime"></param>
  /// <returns></returns>
  /// <remarks>歲煞,常居四季,成為“四季之陰氣”,極其狠毒,能游行天上,所理之地不可穿鑿、修營和移徙。不慎而沖犯這,家中子孫六畜將受傷害。然歲煞巡行的方位卻極易尋覓。子日起正南,向東逆行,一日一位,四日一周,循環往復。</remarks>
  public string getsuisha(datetime solardatetime)
  {
   string[] sfw = new string[] { "南", "東", "北", "西", "南", "東", "北", "西", "南", "東", "北", "西" };
   int dd = zhi(ld(solardatetime));
   return "歲煞" + sfw[dd];
  }
  /// <summary>
  /// 獲取指定甲子數所對應的五行。
  /// </summary>
  /// <param name="x"></param>
  /// <returns></returns>
  public string getwuxing(int x)
  {
   string nyy = string.empty;
   string d = gan(x).tostring() + zhi(x).tostring();
   if (d == "00" || d == "11") nyy = "金";
   if (d == "22" || d == "33") nyy = "火";
   if (d == "44" || d == "55") nyy = "木";
   if (d == "66" || d == "77") nyy = "土";
   if (d == "88" || d == "99") nyy = "金";
   if (d == "010" || d == "111") nyy = "火";
   if (d == "20" || d == "31") nyy = "水";
   if (d == "42" || d == "53") nyy = "土";
   if (d == "64" || d == "75") nyy = "金";
   if (d == "86" || d == "97") nyy = "木";
   if (d == "08" || d == "19") nyy = "水";
   if (d == "210" || d == "311") nyy = "土";
   if (d == "40" || d == "51") nyy = "火";
   if (d == "62" || d == "73") nyy = "木";
   if (d == "84" || d == "95") nyy = "水";
   if (d == "06" || d == "17") nyy = "金";
   if (d == "28" || d == "39") nyy = "火";
   if (d == "410" || d == "511") nyy = "木";
   if (d == "60" || d == "71") nyy = "土";
   if (d == "82" || d == "93") nyy = "金";
   if (d == "04" || d == "15") nyy = "火";
   if (d == "26" || d == "37") nyy = "水";
   if (d == "48" || d == "59") nyy = "土";
   if (d == "610" || d == "711") nyy = "金";
   if (d == "80" || d == "91") nyy = "木";
   if (d == "02" || d == "13") nyy = "水";
   if (d == "24" || d == "35") nyy = "土";
   if (d == "46" || d == "57") nyy = "火";
   if (d == "68" || d == "79") nyy = "木";
   if (d == "810" || d == "911") nyy = "水";
   return nyy;
  }
  /// <summary>
  /// 獲取星宿。
  /// </summary>
  /// <param name="solardatetime"></param>
  /// <returns></returns>
  public string getxingxiu(datetime solardatetime)
  {
   string[] sukuyou = new string[] { "東方角木蛟-吉", "東方亢金龍-兇", "東方氐土貉-兇", "東方房日兔-吉", "東方心月狐-兇", "東方尾火虎-吉", "東方箕水豹-吉", "北方斗木獬-吉", "北方牛金牛-兇", "北方女土蝠-兇", "北方虛日鼠-兇", "北方危月燕-兇", "北方室火豬-吉", "北方壁水貐-吉", "西方奎木狼-兇", "西方婁金狗-吉", "西方胃土雉-吉", "西方昴日雞-兇", "西方畢月烏-吉", "西方觜火猴-兇", "西方參水猿-兇", "南方井木犴-吉", "南方鬼金羊-兇", "南方柳土獐-兇", "南方星日馬-兇", "南方張月鹿-吉", "南方翼火蛇-兇", "南方軫水蚓-吉" };
   int s = (int) (getjulianday(solardatetime) + 12) % 28;
   return sukuyou[s];
  }
  /// <summary>
  /// 獲取六耀。
  /// </summary>
  /// <param name="solardatetime"></param>
  /// <returns></returns>
  public string getliuyao(datetime solardatetime)
  {
   string[] rokuyou = new string[] { "先勝", "友引", "先負", "佛滅", "大安", "赤口" };
   int k = (solardatetime.month + solardatetime.day + 4) % 6;
   return rokuyou[k];
  }
  /// <summary>
  /// 獲取12建星。
  /// </summary>
  /// <param name="solardatetime"></param>
  /// <returns></returns>
  public string get12jianxing(datetime solardatetime)
  {
   string[] jcname0 = new string[] { "建", "除", "滿", "平", "定", "執", "破", "危", "成", "收", "開", "閉" };
   string[] jcname1 = new string[] { "閉", "建", "除", "滿", "平", "定", "執", "破", "危", "成", "收", "開" };
   string[] jcname2 = new string[] { "開", "閉", "建", "除", "滿", "平", "定", "執", "破", "危", "成", "收" };
   string[] jcname3 = new string[] { "收", "開", "閉", "建", "除", "滿", "平", "定", "執", "破", "危", "成" };
   string[] jcname4 = new string[] { "成", "收", "開", "閉", "建", "除", "滿", "平", "定", "執", "破", "危" };
   string[] jcname5 = new string[] { "危", "成", "收", "開", "閉", "建", "除", "滿", "平", "定", "執", "破" };
   string[] jcname6 = new string[] { "破", "危", "成", "收", "開", "閉", "建", "除", "滿", "平", "定", "執" };
   string[] jcname7 = new string[] { "執", "破", "危", "成", "收", "開", "閉", "建", "除", "滿", "平", "定" };
   string[] jcname8 = new string[] { "定", "執", "破", "危", "成", "收", "開", "閉", "建", "除", "滿", "平" };
   string[] jcname9 = new string[] { "平", "定", "執", "破", "危", "成", "收", "開", "閉", "建", "除", "滿" };
   string[] jcname10 = new string[] { "滿", "平", "定", "執", "破", "危", "成", "收", "開", "閉", "建", "除" };
   string[] jcname11 = new string[] { "除", "滿", "平", "定", "執", "破", "危", "成", "收", "開", "閉", "建" };
   int num = zhi(lm(solardatetime));
   int num2 = zhi(ld(solardatetime));
   if (num == 0) return (jcname0[num2]);
   if (num == 1) return (jcname1[num2]);
   if (num == 2) return (jcname2[num2]);
   if (num == 3) return (jcname3[num2]);
   if (num == 4) return (jcname4[num2]);
   if (num == 5) return (jcname5[num2]);
   if (num == 6) return (jcname6[num2]);
   if (num == 7) return (jcname7[num2]);
   if (num == 8) return (jcname8[num2]);
   if (num == 9) return (jcname9[num2]);
   if (num == 10) return (jcname10[num2]);
   if (num == 11) return (jcname11[num2]);
   return "";
  }
  /// <summary>
  /// 獲取值日星神
  /// </summary>
  /// <param name="solardatetime"></param>
  /// <returns></returns>
  public string getxingshen(datetime solardatetime)
  {
   string[] zrxname1 = new string[] { "青龍(黃道日)", "明堂(黃道日)", "天刑(黑道日)", "朱雀(黑道日)", "金匱(黃道日)", "天德(黃道日)", "白虎(黑道日)", "玉堂(黃道日)", "天牢(黑道日)", "玄武(黑道日)", "司命(黃道日)", "勾陳(黑道日)" };
   string[] zrxname2 = new string[] { "司命(黃道日)", "勾陳(黑道日)", "青龍(黃道日)", "明堂(黃道日)", "天刑(黑道日)", "朱雀(黑道日)", "金匱(黃道日)", "天德(黃道日)", "白虎(黑道日)", "玉堂(黃道日)", "天牢(黑道日)", "玄武(黑道日)" };
   string[] zrxname3 = new string[] { "天牢(黑道日)", "玄武(黑道日)", "司命(黃道日)", "勾陳(黑道日)", "青龍(黃道日)", "明堂(黃道日)", "天刑(黑道日)", "朱雀(黑道日)", "金匱(黃道日)", "天德(黃道日)", "白虎(黑道日)", "玉堂(黃道日)" };
   string[] zrxname4 = new string[] { "白虎(黑道日)", "玉堂(黃道日)", "天牢(黑道日)", "玄武(黑道日)", "司命(黃道日)", "勾陳(黑道日)", "青龍(黃道日)", "明堂(黃道日)", "天刑(黑道日)", "朱雀(黑道日)", "金匱(黃道日)", "天德(黃道日)" };
   string[] zrxname5 = new string[] { "金匱(黃道日)", "天德(黃道日)", "白虎(黑道日)", "玉堂(黃道日)", "天牢(黑道日)", "玄武(黑道日)", "司命(黃道日)", "勾陳(黑道日)", "青龍(黃道日)", "明堂(黃道日)", "天刑(黑道日)", "朱雀(黑道日)" };
   string[] zrxname6 = new string[] { "天刑(黑道日)", "朱雀(黑道日)", "金匱(黃道日)", "天德(黃道日)", "白虎(黑道日)", "玉堂(黃道日)", "天牢(黑道日)", "玄武(黑道日)", "司命(黃道日)", "勾陳(黑道日)", "青龍(黃道日)", "明堂(黃道日)" };
   string[] zrxname7 = new string[] { "青龍(黃道日)", "明堂(黃道日)", "天刑(黑道日)", "朱雀(黑道日)", "金匱(黃道日)", "天德(黃道日)", "白虎(黑道日)", "玉堂(黃道日)", "天牢(黑道日)", "玄武(黑道日)", "司命(黃道日)", "勾陳(黑道日)" };
   string[] zrxname8 = new string[] { "司命(黃道日)", "勾陳(黑道日)", "青龍(黃道日)", "明堂(黃道日)", "天刑(黑道日)", "朱雀(黑道日)", "金匱(黃道日)", "天德(黃道日)", "白虎(黑道日)", "玉堂(黃道日)", "天牢(黑道日)", "玄武(黑道日)" };
   string[] zrxname9 = new string[] { "天牢(黑道日)", "玄武(黑道日)", "司命(黃道日)", "勾陳(黑道日)", "青龍(黃道日)", "明堂(黃道日)", "天刑(黑道日)", "朱雀(黑道日)", "金匱(黃道日)", "天德(黃道日)", "白虎(黑道日)", "玉堂(黃道日)" };
   string[] zrxname10 = new string[] { "白虎(黑道日)", "玉堂(黃道日)", "天牢(黑道日)", "玄武(黑道日)", "司命(黃道日)", "勾陳(黑道日)", "青龍(黃道日)", "明堂(黃道日)", "天刑(黑道日)", "朱雀(黑道日)", "金匱(黃道日)", "天德(黃道日)" };
   string[] zrxname11 = new string[] { "金匱(黃道日)", "天德(黃道日)", "白虎(黑道日)", "玉堂(黃道日)", "天牢(黑道日)", "玄武(黑道日)", "司命(黃道日)", "勾陳(黑道日)", "青龍(黃道日)", "明堂(黃道日)", "天刑(黑道日)", "朱雀(黑道日)" };
   string[] zrxname12 = new string[] { "天刑(黑道日)", "朱雀(黑道日)", "金匱(黃道日)", "天德(黃道日)", "白虎(黑道日)", "玉堂(黃道日)", "天牢(黑道日)", "玄武(黑道日)", "司命(黃道日)", "勾陳(黑道日)", "青龍(黃道日)", "明堂(黃道日)" };
   int num = zhi(lm(solardatetime));
   int num2 = zhi(ld(solardatetime));
   if (num == 2)
    return (zrxname1[num2]);
   if (num == 3)
    return (zrxname2[num2]);
   if (num == 4)
    return (zrxname3[num2]);
   if (num == 5)
    return (zrxname4[num2]);
   if (num == 6)
    return (zrxname5[num2]);
   if (num == 7)
    return (zrxname6[num2]);
   if (num == 8)
    return (zrxname7[num2]);
   if (num == 9)
    return (zrxname8[num2]);
   if (num == 10)
    return (zrxname9[num2]);
   if (num == 11)
    return (zrxname10[num2]);
   if (num == 0)
    return (zrxname11[num2]);
   if (num == 1)
    return (zrxname12[num2]);
   return "";
  }
  /// <summary>
  /// 獲取九星。
  /// </summary>
  /// <param name="solardatetime"></param>
  /// <returns></returns>
  public string getjiuxing(datetime solardatetime)
  {
   string[] kyuuseiname = new string[] { "一白-太乙星(水)-吉神", "二黒-攝提星(土)-兇神", "三碧-軒轅星(木)-安神", "四緑-招搖星(木)-安神", "五黃-天符星(土)-兇神", "六白-青龍星(金)-吉神", "七赤-咸池星(金)-兇神", "八白-太陰星(土)-吉神", "九紫-天乙星(火)-吉神" };
   return kyuuseiname[jd2kyuusei(getjulianday(solardatetime))];
  }
  /// <summary>
  /// 獲取幾牛耕田。
  /// </summary>
  /// <param name="year"></param>
  /// <returns></returns>
  /// <remarks>每年第一個丑日(丑為牛)在正月初幾,就是“幾牛耕田”。耕田的牛是多多益善,越多越好</remarks>
  public string getliugentian(int year)
  {
   int i = zhi(getchineseeraofday(new datetime(year, 1, 1, netcalendar)));
   int t = (15 - i) % 12;
   string s = tostringwithchineseday(t);
   if (t <= 10)
   {
    s = s.substring(1);
   }
   return s + "牛耕田";
  }
  /// <summary>
  /// 獲取幾龍治水。
  /// </summary>
  /// <param name="year"></param>
  /// <returns></returns>
  /// <remarks>是根據每年正月第一個辰日(辰為龍)在第幾日決定的。如在正月初五,就叫“五龍治水”,在初六,就叫“六龍治水”,等等。據說,龍數越多,雨量越少,龍數越少,雨量就越多。民間自古就有“龍多不下雨”的諺語。</remarks>
  public string getlongzhisui(int year)
  {
   int i = zhi(getchineseeraofday(new datetime(year, 1, 1, netcalendar)));
   int t = (18 - i) % 12;
   string s = tostringwithchineseday(t);
   if (t <= 10)
   {
    s = s.substring(1);
   }
   return s + "龍治水";
  }
#endregion
#region 計算
  private int ld(datetime solardatetime)
  {
   double daycyclical = microsoft.jscript.dateconstructor.utc(solardatetime.year, solardatetime.month - 1, 1, 0, 0, 0, 0) / 86400000 + 25567 + 9;
   return (int) (daycyclical + solardatetime.day);
  }
  private int lm(datetime solardatetime)
  {
   int num = (solardatetime.year - 1900) * 12 + solard, atetime.month + 11;
   if ((solardatetime.day + 1) >= getsolarterm(solardatetime)[0].solartermdatetime.day)
   {
    num += 1;
   }
   return num;
  }
int[] nkyuusei = new int[] { -1, -1, -1 };
  private int jd2kyuusei(double jd)
  {
   int flag, b;
   int jd = (int) math.floor(jd);
   if ((jd < nkyuusei[0]) || (jd >= nkyuusei[0] + nkyuusei[1]))
   {
    if (gettenton(jd) < 0) return -1;
   }
   if (nkyuusei[2] < 0)
   {
    flag = -1;
   }
   else
   {
    flag = 1;
   }
   b = flag * nkyuusei[2] - 1 + 270;
   b += (jd - nkyuusei[0]) * flag;
   return b % 9;
  }
  private int gettenton(int jd)
  {
   int[] kyuuseijd = new int[] { 2404030, 2404600, 2404810, 2408800, 2409010, 2413000, 2413210, 2417200, 2417410, 2421220, 2421400, 2421610, 2425420, 2425630, 2429620, 2429800, 2430010, 2433820, 2434030, 2438020, 2438230, 2442220, 2442430, 2446420, 2446630, 2450620, 2450830, 2454820, 2455030, 2458840, 2459020, 2459230, 2463250, 2467240, 2467420, 2467630, 2471440, 2471650, 2475640, 2475850, 2477650 };
   int[] kyuuseijdf = new int[] { 1, -3, 1, 7, -9, -3, 1, 7, -9, 7, -3, 1, -3, 1, 7, -3, 1, -3, 1, 7, -9, -3, 1, 7, -9, -3, 1, 7, -9, 7, -3, 1, 1, 7, -3, 1, -3, 1, 7, -9, -9 };
   int kjd = 0, kjdf = 0, n = 0;
   int ne = kyuuseijd.length;
   if (jd < kyuuseijd[0]) return -1;
   if (jd >= kyuuseijd[ne - 1]) return -1;
   for (n = 1 ; n < ne ; n++)
   {
    if (jd < kyuuseijd[n])
    {
     kjd = kyuuseijd[n - 1];
     kjdf = kyuuseijdf[n - 1];
     ne = kyuuseijd[n];
     break;
    }
   }
   do
   {
    nkyuusei[0] = kjd;
    kjd += 180;
    if (kjd + 61 > ne) { kjd = ne; }
    if (jd >= kjd)
    {
     kjdf = (kjdf < 0) ? 1 : -9;
    }
   } while (jd >= kjd);
   nkyuusei[1] = kjd - nkyuusei[0];
   nkyuusei[2] = kjdf;
   return nkyuusei[0];
  }
  /// <summary>
  /// 判斷y年m月(1,2,..,12,下同)d日是gregorian歷還是julian歷(opt=1,2,3分別表示標準日歷,gregorge歷和julian歷),是則返回1,是julian歷則返回0,若是gregorge歷所刪去的那10天則返回-1
  /// </summary>
  private int ifgregorian(int y, int m, int d, int opt)
  {
   if (opt == 1)
   {
    if (y > 1582 || (y == 1582 && m > 10) || (y == 1582 && m == 10 && d > 14))
     return (1);  //gregorian
    else
     if (y == 1582 && m == 10 && d >= 5 && d <= 14)
      return (-1);  //空
     else
      return (0);  //julian
   }
   if (opt == 2)
    return (1);  //gregorian
   if (opt == 3)
    return (0);  //julian
   retur, n (-1);
  }
  /// <summary>
  /// 返回等效標準天數(y年m月d日相應歷種的1年1月1日的等效(即對gregorian歷與julian歷是統一的)天數)
  /// </summary>
  private double equivalentstandardday(int y, int m, int d)
  {
   double v = (y - 1) * 365 + math.floor((double) ((y - 1) / 4)) + daydifference(y, m, d) - 2;  //julian的等效標準天數
   if (y > 1582)
    v += -math.floor((double) ((y - 1) / 100)) + math.floor((double) ((y - 1) / 400)) + 2;  //gregorian的等效標準天數
   return v;
  }
  /// <summary>
  /// 返回陽歷y年m月d日的日差天數(在y年年內所走過的天數,如2000年3月1日為61)
  /// </summary>
  private int daydifference(int y, int m, int d)
  {
   int ifg = ifgregorian(y, m, d, 1);
   int[] monl = { 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
   if (ifg == 1)
    if ((y % 100 != 0 && y % 4 == 0) || (y % 400 == 0))
     monl[2] += 1;
    else
     if (y % 4 == 0)
      monl[2] += 1;
   int v = 0;
   for (int i = 0 ; i <= m - 1 ; i++)
   {
    v += monl[i];
   }
   v += d;
   if (y == 1582)
   {
    if (ifg == 1)
     v -= 10;
    if (ifg == -1)
     v = 0;  //infinity 
   }
   return v;
  }
  //原始:s
  /// <summary>
  ///返回y年第n個節氣(如小寒為1)的日差天數值(pd取值真假,分別表示平氣和定氣)
  /// </summary>
  private double term(int y, int n, bool pd)
  {
   double jud = y * (365.2423112 - 6.4e-14 * (y - 100) * (y - 100) - 3.047e-8 * (y - 100)) + 15.218427 * n + 1721050.71301;//儒略日
   double tht = 3e-4 * y - 0.372781384 - 0.2617913325 * n;//角度
   double yrd = (1.945 * math.sin(tht) - 0.01206 * math.sin(2 * tht)) * (1.048994 - 2.583e-5 * y);//年差實均數
   double shuod = -18e-4 * math.sin(2.313908653 * y - 0.439822951 - 3.0443 * n);//朔差實均數
   double vs = (pd) ? (jud + yrd + shuod - equivalentstandardday(y, 1, 0) - 1721425) : (jud - equivalentstandardday(y, 1, 0) - 1721425);
   return vs;
  }
  /// <summary>
  /// 返回陽歷y年日差天數為x時所對應的月日數(如y=2000,x=274時,返回1001(表示10月1日,即返回100*m+d))
  /// </summary>
  private double antidaydifference(int y, double x)
  {
   int m = 1;
   for (int j = 1 ; j <= 12 ; j++)
   {
    int ml = daydifference(y, j + 1, 1) - daydifference(y, j, 1);
    if (x <= ml || j == 12)
    {
     m = j;
     break;
    }
    else
     x -= ml;
   }
   return 100 * m + x;
  }
  //原始:tail
  /// <summary>
  /// 返回x的小數尾數,若x為負值,則是1-小數尾數
  /// </summary>
  private double tail(double x)
  {
   return x - math.floor(x);
  }
  //原始:ang
  /// <summary>
  /// 角度函數
  /// </summary>
  private double angle(double x, double t, double c1, double t0, double t2, double t3)
  {
   return tail(c1 * x) * 2 * math.pi + t0 - t2 * t * t - t3 * t * t * t;
  }
  /// <summary>
  /// 廣義求余
  /// </summary>
  private double rem(double x, double w)
  {
   return tail((x / w)) * w;
  }
  /// <summary>
  /// 返回甲子數x對應的天干數(如33為3)
  /// </summary>
  private int gan(int x)
  {
   return x % 10;
  }
  /// <summary>
  /// 返回甲子數x對應的地支數(如33為9)
  /// </summary>
  private int zhi(int x)
  {
   return x % 12;
  }
#endregion
#region 節日紀念日
  /// <summary>
  /// 獲取公歷節日字符串。
  /// </summary>
  public string getholiday(datetime solardatetime)
  {
   string re = "";
   foreach (string s in holiday)
   {
    if (solardatetime.month == convert.toint32(s.substring(0, 2)))
    {
     if (solardatetime.day == convert.toint32(s.substring(2, 2)))
     {
      re = s.substring(4);
      break;
     }
    }
   }
   return re;
  }
  /// <summary>
  /// 獲取名人紀念日字符串。
  /// </summary>
  public string getcommemoration(datetime solardatetime)
  {
   string re = "";
   foreach (string s in celebrity)
   {
    if (solardatetime.month == convert.toint32(s.substring(0, 2)))
    {
     if (solardatetime.day == convert.toint32(s.substring(2, 2)))
     {
      re = s.substring(4);
      break;
     }
    }
   }
   return re;
  }
  /// <summary>
  /// 獲取中國農歷節日字符串。
  /// </summary>
  public string getchineseholiday(datetime solardatetime)
  {
   string re = "";
   int mon = netcalendar.getmonth(solardatetime);
   if (mon >= netcalendar.getleapmonth(solardatetime.year))
    mon -= 1;
   foreach (string s in chineseholiday)
   {
    if (mon == convert.toint32(s.substring(0, 2)))
    {
     if (netcalendar.getdayofmonth(solardatetime) == convert.toint32(s.substring(2, 2)))
     {
      re = s.substring(4);
      break;
     }
    }
   }
   //梅雨
   int y = solardatetime.year;
   int thisd0 = getdayofyear(solardatetime);
   int dg = gan(getchineseeraofday(solardatetime));
   int dz = zhi(getchineseeraofday(solardatetime));
   int s11 = (int) math.floor(term(y, 11, true));
   if (thisd0 >= s11 && thisd0 < s11 + 10 && dg == 3)
    re += " 入梅";
   int s13 = (int) math.floor(term(y, 13, true));
   if (thisd0 >= s13 && thisd0 < s13 + 12 && dz == 8)
    re += " 出梅";
   //  "三伏"是指初伏、中伏和末伏,約在7月中旬到8月中旬這一段時間。夏至以后,雖然白天漸短,黑夜漸長,但是一天當中,白天還比黑夜長,每天地面吸收的熱量仍比散發的多,近地面的溫度也就一天比一天高。到"三伏"期間,地面吸收的熱量幾乎少于散發的熱量,天氣也就最熱了。再往后,地面吸收的熱量開始少于地面散發的熱量,溫度也就慢慢下降了。所以一年中最熱的時候一般出現在夏至的"三伏"。
   //  從夏至后第三個“庚”日算起,初伏(10天)、中伏(10~20天)、末伏(立秋后的第一個庚日算起,10天),是一年中天氣最熱的時間。
   //夏九九歌謠
   //  “冬至”數九過冬寒,有的地方也有“夏至”數九過酷暑的歌謠。
   //  “夏九九歌”:夏至入頭九,羽扇握在手;二九一十八,脫冠著羅紗;三九二十七,出門汗欲滴;四九三十六,渾身汗濕透;五九四十五,炎秋似老虎;六九五十四,乘涼進廟祠;七九六十三,床頭摸被單;八九七十二,半夜尋被子;九九八十一,開柜拿棉衣 
   //三伏
   int s12 = (int) math.floor(term(y, 12, true));
   int s15 = (int) math.floor(term(y, 15, true));
   int n = (dg - 7) % 10 + 1;
   if (n <= 0)
    n += 10;
   int firsrd0 = thisd0 - n + 1;
   if (firsrd0 >= s12 + 20 && firsrd0 < s12 + 30)
    re += " 初伏第" + n.tostring() + "天";
   if (firsrd0 >= s15 && firsrd0 < s15 + 10)
    re += " 末伏第" + n.tostring() + "天";
   else
   {
    if (firsrd0 >= s12 + 30 && firsrd0 < s12 + 40)
     re += " 中伏第" + n.tostring() + "天";
    if (firsrd0 >= s12 + 40 && firsrd0 < s12 + 50)
     re += " 中伏第" + (n + 10).tostring() + "天";
   }
   //  "三九"是指冬至后的第三個九天,約在1月中下旬。"三九"天為什么最冷呢?這要從當時地面吸收和散發熱量的多少來看,冬季這時候雖然白晝短,地面吸收的太陽輻射熱量最少,但此時地面散發的熱量還多于吸收的熱量,近地面的空氣溫度還要繼續低下去,當地面吸收到的太陽熱量幾乎等于地面散發的熱量,氣溫才達到最冷。到"三九"以后,地面吸收的熱量又將多于地面散失的熱量,近地面的空氣溫度也隨著逐漸回升。因此,一年中最冷的時候一般出現在冬至后的"三九"前后。
   //  冬至這一天開始數九,這就是人們所說的“提冬數九”。數上9天是一九,再數9天是二九……數到“九九”就算“九”盡了,“九盡楊花開”,那時天就暖了。
   //  人說“冷在九、熱在伏”,數九雖冷,但由于我國地域遼闊,冷也冷得不一樣:
   //  黃河中下游的《九九歌》是:一九二九不出手;三九四 九河上走;五九六九沿河望柳;七九開河,八九雁來;九九又一九,耕牛遍地走。
   //  江南的《九九歌》是:一九二九相見弗出手;三九二十七,籬頭吹篳篥(古代的一種樂器,意指寒風吹得籬笆噼噼響聲);四九三十六,夜晚如鷺宿(晚上寒冷象白鶴一樣卷曲著身體睡眠);五九四十五,太陽開門戶,六九五十四,貧兒爭意氣;七九六十三,布袖擔頭擔;八九七十二,貓兒尋陽地;九九八十一,犁耙一齊出。
   //  最冷的是三九、四九,在吉林:三九四九凍死狗,在江蘇則是“三九四九拾糞老漢滿街游”,可見氣溫相差很大。 
   //九九
   int s24 = (int) math.floor(term(y, 24, true));
   int s_24 = (int) math.floor(term(y - 1, 24, true));
   int d1 = thisd0 - s24;
   datetime a1 = new datetime(y - 1, 12, 31);
   //datetime a2=new datetime(y-1,1,0);
   int d2 = thisd0 - s_24 + a1.dayofyear - 1;
   int w, v;
   if (d1 >= 0 || d2 <= 80)
   {
    if (solardatetime.month == 12)
    {
     w = 1;
     v = d1 + 1;
     if (v > 9)
     {
      w += 1;
      v -= 9;
     }
    }
    else
    {
     w = (int) math.floor((double) d2 / 9) + 1;
     v = (int) math.round(rem(d2, 9)) + 1;
    }
    re += " " + tostringwithchineseday(w).substring(1, 1) + "九第" + v.tostring() + "天";
   }
   return re;
  }
  #region 節日變量
  private string[] holiday ={
            "0101元旦",
            "0202世界濕地日",
            "0207國際聲援南非日",
            "0210國際氣象節",
            "0214情人節",
            "0301國際海豹日",
            "0303全國愛耳日",
            "0305學雷鋒活動日",
            "0308國際婦女節",
            "0312植樹節",
            "0314國際警察日",
            "0315消費者權益日",
            "0317中國國醫節 國際航海日",
            "0321世界森林日 消除種族歧視國際日 世界兒歌日",
            "0322世界水日",
            "0323世界氣象日",
            "0324世界防治結核病日",
            "0325全國中小學生安全教育日",
            "0330巴勒斯坦國土日",
            "0401愚人節",
            "0407世界衛生日",
            "0422世界地球日",
            "0423世界圖書和版權日",
            "0424亞非新聞工作者日",
            "0501國際勞動節",
            "0504五四青年節",
            "0505碘缺乏病防治日",
            "0508世界紅十字日",
            "0512國際護士節",
            "0515國際家庭日",
            "0517世界電信日",
            "0518國際博物館日",
            "0520全國學生營養日",
            "0523國際牛奶日",
            "0531世界無煙日",
            "0601國際兒童節",
            "0605世界環境日",
            "0606全國愛眼日",
            "0617防治荒漠化和干旱日",
            "0623國際奧林匹克日",
            "0625全國土地日",
            "0626國際反毒品日",
            "0701中國共產黨建黨日 香港回歸紀念日 世界建筑日",
            "0702國際體育記者日",
            "0707中國人民抗日戰爭紀念日",
            "0711世界人口日",
            "0730非洲婦女日",
            "0801八一建軍節",
            "0908國際掃盲日",
            "0910中國教師節",
            "0914世界清潔地球日",
            "0916國際和平日 國際臭氧層保護日",
            "0918九·一八事變紀念日",
            "0920作者的生日 國際愛牙日",
            "0927世界旅游日",
            "1001國慶節 國際音樂日 國際老人節",
            "1002國際和平與民主自由斗爭日",
            "1004世界動物日",
            "1005世界住房日",
            "1008全國高血壓日 世界視覺日",
            "1009世界郵政日",
            "1010辛亥革命紀念日 世界精神衛生日",
            "1013世界保健日 國際教師節",
            "1014世界標準日",
            "1015國際盲人節(白手杖節)",
            "1016世界糧食日",
            "1017世界消除貧困日",
            "1022世界傳統醫藥日",
            "1024聯合國日 世界發展信息日",
            "1031世界勤儉日 萬圣節前夜",
            "1107十月社會主義革命紀念日",
            "1108中國記者日",
            "1109全國消防安全宣傳教育日",
            "1110世界青年節",
            "1114世界糖尿病日",
            "1117國際大學生節 世界學生節",
            "1121世界問候日 世界電視日",
            "1129國際聲援巴勒斯坦人民國際日",
            "1201世界愛滋病日",
            "1203世界殘疾人日",
            "1205國際經濟和社會發展志愿人員日",
            "1208國際兒童電視日",
            "1209紀念一二·九運動 世界足球日",
            "1210世界人權日",
            "1212西安事變紀念日",
            "1213南京大屠殺(1937年)紀念日!緊記血淚史!",
            "1221國際籃球日",
            "1224平安夜",
            "1220澳門回歸紀念日",
            "1225圣誕節",
            "1229國際生物多樣性日"
        };
  private string[] chineseholiday ={
            "0101新年",
            "0103天慶節",
            "0105五路財神日",
            "0108江東神誕",
            "0109昊天皇帝誕",
            "0111太均娘娘誕",
            "01139散花燈 哥升節",
            "0115元宵節",
            "0116餛飩節 門神誕",
            "0119丘處機誕",
            "0120女媧補天日 黃道婆祭",
            "0125填倉節",
            "0127天地水三官誕",
            "0202龍頭節 太昊伏羲氏祭",
            "0203文昌誕",
            "0208芳春節 插花節",
            "0210彩蛋節",
            "0212花朝節",
            "0215老子誕",
            "0219觀音誕",
            "0228寒潮節 岱誕",
            "0303上巳節 踏青節",
            "0305大禹誕",
            "0310撒種節",
            "0315孫臏誕 龍華會",
            "0316蒙恬誕",
            "0318中岳節",
            "0320魯班誕",
            "0322子孫娘娘誕",
            "0323天后瑪祖誕",
            "0328倉頡先師誕",
            "0401清和節",
            "0402公輸般日",
            "0408洗佛放生節 牛王誕 跳月節",
            "0410葛洪誕",
            "0411孔子祭",
            "0414呂洞賓誕 菖蒲日",
            "0415鐘離權誕 外薩卡佛陀日",
            "0417金花女誕",
            "0418錫伯遷移節",
            "0419浣花日",
            "0426炎帝神農氏誕",
            "0428扁鵲誕",
            "0501女兒節",
            "0504采花節",
            "0505端午節",
            "0511范蠡祭",
            "0513關羽誕",
            "0522曹娥日",
            "0529祖娘節",
            "0606天貺節 盤古逝",
            "0612彭祖箋鏗誕",
            "0615捕魚祭",
            "0616爬坡節",
            "0619太陽日 觀音日",
            "0623火神誕",
            "0624觀蓮節",
            "0707乞巧節",
            "0712地獄開門日",
            "0713軒轅誕",
            "0715中元節",
            "0723諸葛亮誕",
            "0727黃老誕",
            "0801天醫節",
            "0803華佗誕",
            "0815中秋節",
            "0818觀潮節",
            "0824稻節",
            "0909重陽節",
            "0913釘鞋日",
            "0916伯余誕",
            "0919觀音逝",
            "0930采參節",
            "1001送寒衣節 祭祖節",
            "1015下元節 文成公主誕",
            "1016盤古節",
            "1208臘八節",
            "1212百福日 蠶花娘娘誕",
            "1223洗灶日",
            "1224小年",
            "1225上帝下界之辰"
        };
  private string[] celebrity ={
            "0104雅各布·格林誕辰",
            "0108周恩來逝世紀念日",
            "0106圣女貞德誕辰",
            "0112杰克·倫敦誕辰",
            "0115莫里哀誕辰",
            "0117富蘭克林誕辰",
            "0119瓦特誕辰",
            "0122培根誕辰",
            "0123郎之萬誕辰",
            "0127莫扎特誕辰",
            "0129羅曼·羅蘭誕辰",
            "0130甘地誕辰",
            "0131舒柏特誕辰",
            "0203門德爾松誕辰",
            "0207門捷列夫誕辰",
            "0211愛迪生誕辰,狄更斯誕辰",
            "0212林肯,達爾文誕辰",
            "0217布魯諾誕辰",
            "0218伏打誕辰",
            "0219哥白尼誕辰",
            "0222赫茲,叔本華,華盛頓誕辰",
            "0226雨果誕辰",
            "0302斯美塔那誕辰",
            "0304白求恩誕辰",
            "0305周恩來誕辰",
            "0306布朗寧,米開朗琪羅誕辰",
            "0307竺可楨誕辰",
            "0314愛因斯坦誕辰",
            "0321巴赫,穆索爾斯基誕辰",
            "0322賀龍誕辰",
            "0328高爾基誕辰",
            "0401海頓,果戈理誕辰",
            "0415達·芬奇誕辰",
            "0416卓別林誕辰",
            "0420祖沖之誕辰",
            "0422列寧,康德,奧本海默誕辰",
            "0423普朗克,莎士比亞誕辰",
            "0430高斯誕辰",
            "0505馬克思誕辰",
            "0507柴可夫斯基,泰戈爾誕辰",
            "0511冼星海誕辰",
            "0511李比希誕辰",
            "0520巴爾扎克誕辰",
            "0522瓦格納誕辰",
            "0531惠特曼誕辰",
            "0601杜威誕辰",
            "0602哈代誕辰",
            "0608舒曼誕辰",
            "0715倫勃朗誕辰",
            "0805阿貝爾誕辰",
            "0808狄拉克誕辰",
            "0826陳毅誕辰",
            "0828歌德誕辰",
            "0909毛澤東逝世紀念日",
            "0925魯迅誕辰",
            "0926巴甫洛夫誕辰",
            "0928孔子誕辰",
            "0929奧斯特洛夫斯基誕辰",
            "1011伯遼茲誕辰",
            "1021諾貝爾誕辰",
            "1022李斯特誕辰",
            "1026伽羅瓦誕辰",
            "1029李大釗誕辰",
            "1007居里夫人誕辰",
            "1108哈雷誕辰",
            "1112孫中山誕辰",
            "1124劉少奇誕辰",
            "1128恩格斯誕辰",
            "1201朱德誕辰",
            "1205海森堡誕辰",
            "1211玻恩誕辰",
            "1213海涅誕辰",
            "1216貝多芬誕辰",
            "1221斯大林誕辰",
            "1225牛頓誕辰",
            "1226毛澤東誕辰",
            "1229阿·托爾斯泰誕辰"
        };
  #endregion
  #endregion
 }
 public class solarterm
 {
  private datetime solartermdate;
  private string name;
  /// <summary>
  /// 節氣的時間。
  /// </summary>
  public datetime solartermdatetime
  {
   get
   {
    return solartermdate;
   }
   set
   {
    solartermdate = value;
   }
  }
  /// <summary>
  /// 節氣名。
  /// </summary>
  public string name
  {
   get
   {
    return name;
   }
   set
   {
    name = value;
   }
  }
 }
 public enum syzygy
 {
  /// <summary>
  /// 非朔非望。(即看到不完整的月亮)
  /// </summary>
  none,
  /// <summary>
  /// 新月,即朔。
  /// </summary>
  newmoon,
  /// <summary>
  /// 滿月,即望。
  /// </summary>
  fullmoon,
 }
 public enum eclipsephenomena
 {
  /// <summary>
  /// 不食。(大概是天狗沒有食欲的樣子)
  /// </summary>
  none,
  /// <summary>
  /// 日食
  /// </summary>
  eclipseofsun,
  /// <summary>
  /// 月全食
  /// </summary>
  completeeclipseofthemoon,
  /// <summary>
  /// 月偏食
  /// </summary>
  partialeclipseofthemoon,
 }
 public class eclipse
 {
  private datetime eclipsetime;
  private eclipsephenomena phenomena;
  private syzygy syzygy;
  /// <summary>
  /// 日食月食的時間
  /// </summary>
  public datetime datetime
  {
   get
   {
    return eclipsetime;
   }
   set
   {
    eclipsetime = value;
   }
  }
  /// <summary>
  /// 日食月食的類型
  /// </summary>
  public eclipsephenomena phenomena
  {
   get
   {
    return phenomena;
   }
   set
   {
    phenomena = value;
   }
  }
  /// <summary>
  /// 朔望
  /// </summary>
  public syzygy syzygy
  {
   get
   {
    return syzygy;
   }
   set
   {
    syzygy = value;
   }
  }
 }
}
 
新聞熱點
疑難解答
圖片精選