欧美大屁股bbbbxxxx,狼人大香伊蕉国产www亚洲,男ji大巴进入女人的视频小说,男人把ji大巴放进女人免费视频,免费情侣作爱视频

歡迎來到入門教程網(wǎng)!

C#教程

當前位置:主頁 > 軟件編程 > C#教程 >

C#實現(xiàn)的陰歷陽歷互相轉(zhuǎn)化類實例

來源:本站原創(chuàng)|時間:2020-01-10|欄目:C#教程|點擊: 次

本文實例講述了C#實現(xiàn)的陰歷陽歷互相轉(zhuǎn)化類。分享給大家供大家參考,具體如下:

最近郁悶地發(fā)現(xiàn)網(wǎng)上現(xiàn)有的相當一部分萬年歷上干支紀年的算法都是錯誤的。因為干支紀年是針對陰歷而言的,而生肖屬相又跟地支對應(yīng),所以元旦和春節(jié)之間那段時間在干支紀年法中應(yīng)該歸上一年,以陽歷2007年2月9日為例,當日的陰歷日期是二〇〇六年十二月廿二日,是丙戌年,即狗年,但是瀏覽一下目前的萬年歷,相當一部分都顯示成了丁亥年,豬年,比較郁悶~~

然后就寫了一個陰歷陽歷互相轉(zhuǎn)化的類。

相關(guān)代碼如下:

/// <summary>
/// 中國日歷信息實體類
/// </summary>
public sealed class ChineseCalendarInfo
{
    private DateTime m_SolarDate;
    private int m_LunarYear, m_LunarMonth, m_LunarDay;
    private bool m_IsLeapMonth = false;
    private string m_LunarYearSexagenary = null, m_LunarYearAnimal = null;
    private string m_LunarYearText = null, m_LunarMonthText = null, m_LunarDayText = null;
    private string m_SolarWeekText = null, m_SolarConstellation = null, m_SolarBirthStone = null;
    日歷屬性
    /// <summary>
    /// 根據(jù)指定陽歷日期計算星座&誕生石
    /// </summary>
    /// <param name="date">指定陽歷日期</param>
    /// <param name="constellation">星座</param>
    /// <param name="birthstone">誕生石</param>
    public static void CalcConstellation(DateTime date, out string constellation, out string birthstone)
    {
      int i = Convert.ToInt32(date.ToString("MMdd"));
      int j;
      if (i >= 321 && i <= 419)
        j = 0;
      else if (i >= 420 && i <= 520)
        j = 1;
      else if (i >= 521 && i <= 621)
        j = 2;
      else if (i >= 622 && i <= 722)
        j = 3;
      else if (i >= 723 && i <= 822)
        j = 4;
      else if (i >= 823 && i <= 922)
        j = 5;
      else if (i >= 923 && i <= 1023)
        j = 6;
      else if (i >= 1024 && i <= 1121)
        j = 7;
      else if (i >= 1122 && i <= 1221)
        j = 8;
      else if (i >= 1222 || i <= 119)
        j = 9;
      else if (i >= 120 && i <= 218)
        j = 10;
      else if (i >= 219 && i <= 320)
        j = 11;
      else
      {
        constellation = "未知星座";
        birthstone = "未知誕生石";
        return;
      }
      constellation = Constellations[j];
      birthstone = BirthStones[j];
      星座劃分
    }
    陰歷轉(zhuǎn)陽歷
    從陰歷創(chuàng)建日歷
    private static ChineseLunisolarCalendar calendar = new ChineseLunisolarCalendar();
    public const string ChineseNumber = "〇一二三四五六七八九";
    public const string CelestialStem = "甲乙丙丁戊己庚辛壬癸";
    public const string TerrestrialBranch = "子丑寅卯辰巳午未申酉戌亥";
    public const string Animals = "鼠?;⑼谬埳唏R羊猴雞狗豬";
    public static readonly string[] ChineseWeekName = new string[] { "星期天", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
    public static readonly string[] ChineseDayName = new string[] {
      "初一","初二","初三","初四","初五","初六","初七","初八","初九","初十",
      "十一","十二","十三","十四","十五","十六","十七","十八","十九","二十",
      "廿一","廿二","廿三","廿四","廿五","廿六","廿七","廿八","廿九","三十"};
    public static readonly string[] ChineseMonthName = new string[] { "正", "二", "三", "四", "五", "六", "七", "八", "九", "十", "十一", "十二" };
    public static readonly string[] Constellations = new string[] { "白羊座", "金牛座", "雙子座", "巨蟹座", "獅子座", "處女座", "天秤座", "天蝎座", "射手座", "摩羯座", "水瓶座", "雙魚座" };
    public static readonly string[] BirthStones = new string[] { "鉆石", "藍寶石", "瑪瑙", "珍珠", "紅寶石", "紅條紋瑪瑙", "藍寶石", "貓眼石", "黃寶石", "土耳其玉", "紫水晶", "月長石,血石" };
}

附:完整實例代碼點擊此處本站下載

PS:這里再為大家推薦幾款日歷相關(guān)在線工具供大家參考:

網(wǎng)頁萬年歷日歷:
http://tools.jb51.net/bianmin/webwannianli

在線陰歷/陽歷轉(zhuǎn)換工具:
http://tools.jb51.net/bianmin/yinli2yangli

在線萬年歷日歷:
http://tools.jb51.net/bianmin/wannianli

在線萬年歷黃歷flash版:
http://tools.jb51.net/bianmin/flashwnl

另外,本站歷史上的今天也有相似的農(nóng)歷日期顯示功能:

http://tools.jb51.net/bianmin/lishi

更多關(guān)于C#相關(guān)內(nèi)容感興趣的讀者可查看本站專題:《C#日期與時間操作技巧總結(jié)》、《C#字符串操作技巧總結(jié)》、《C#數(shù)組操作技巧總結(jié)》、《C#常見控件用法教程》、《WinForm控件用法總結(jié)》、《C#數(shù)據(jù)結(jié)構(gòu)與算法教程》及《C#面向?qū)ο蟪绦蛟O(shè)計入門教程》

希望本文所述對大家C#程序設(shè)計有所幫助。

上一篇:C#多線程數(shù)組模擬socket

欄    目:C#教程

下一篇:C# 的析構(gòu)以及垃圾回收實例分析

本文標題:C#實現(xiàn)的陰歷陽歷互相轉(zhuǎn)化類實例

本文地址:http://mengdiqiu.com.cn/a1/C_jiaocheng/5624.html

網(wǎng)頁制作CMS教程網(wǎng)絡(luò)編程軟件編程腳本語言數(shù)據(jù)庫服務(wù)器

如果侵犯了您的權(quán)利,請與我們聯(lián)系,我們將在24小時內(nèi)進行處理、任何非本站因素導(dǎo)致的法律后果,本站均不負任何責(zé)任。

聯(lián)系QQ:835971066 | 郵箱:835971066#qq.com(#換成@)

Copyright © 2002-2020 腳本教程網(wǎng) 版權(quán)所有