⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 chinesecalendar.cs

📁 破解的飞信源代码
💻 CS
字号:
namespace Imps.Utils
{
    using System;
    using System.Globalization;
    using System.Runtime.InteropServices;

    public class ChineseCalendar
    {
        private DateTime _datetime;
        public ChineseLunisolarCalendar _luar;
        private string[] ConstellationName;
        private const ushort END_YEAR = 0x802;
        private int[] giHoroscope;
        private const ushort START_YEAR = 0x76d;

        public ChineseCalendar()
        {
            this.ConstellationName = new string[] { "魔羯座", "水瓶座", "双鱼座", "白羊座", "金牛座", "双子座", "巨蟹座", "狮子座", "处女座", "天秤座", "天蝎座", "射手座" };
            this.giHoroscope = new int[] { 20, 0x13, 0x15, 20, 0x15, 0x16, 0x17, 0x17, 0x17, 0x18, 0x17, 0x16 };
            this._luar = new ChineseLunisolarCalendar();
            this._datetime = DateTime.Now;
        }

        public ChineseCalendar(DateTime dt)
        {
            this.ConstellationName = new string[] { "魔羯座", "水瓶座", "双鱼座", "白羊座", "金牛座", "双子座", "巨蟹座", "狮子座", "处女座", "天秤座", "天蝎座", "射手座" };
            this.giHoroscope = new int[] { 20, 0x13, 0x15, 20, 0x15, 0x16, 0x17, 0x17, 0x17, 0x18, 0x17, 0x16 };
            this._luar = new ChineseLunisolarCalendar();
            this._datetime = dt;
        }

        public ChineseCalendar(string sDate)
        {
            this.ConstellationName = new string[] { "魔羯座", "水瓶座", "双鱼座", "白羊座", "金牛座", "双子座", "巨蟹座", "狮子座", "处女座", "天秤座", "天蝎座", "射手座" };
            this.giHoroscope = new int[] { 20, 0x13, 0x15, 20, 0x15, 0x16, 0x17, 0x17, 0x17, 0x18, 0x17, 0x16 };
            this._luar = new ChineseLunisolarCalendar();
            this._datetime = new DateTime();
            try
            {
                if (!DateTime.TryParse(sDate, ref this._datetime))
                {
                    throw new ArgumentOutOfRangeException("Error DateTime Format");
                }
            }
            catch
            {
                throw new ArgumentOutOfRangeException("Error DateTime Format");
            }
        }

        public int FormatHoroscope(out string sHoroscope)
        {
            int month = this._datetime.Month;
            int day = this._datetime.Day;
            if ((month == 0) || (day == 0))
            {
                sHoroscope = "";
                return 0;
            }
            int num3 = (month * 100) + day;
            int index = (num3 - this.giHoroscope[month - 1]) / 100;
            if (index >= 12)
            {
                index -= 12;
            }
            sHoroscope = this.ConstellationName[index];
            return (index + 1);
        }

        public string LunarAnimal
        {
            get
            {
                string text = "鼠牛虎兔龙蛇马羊猴鸡狗猪";
                int year = this._luar.GetYear(this._datetime);
                return text.Substring((year - 4) % 12, 1);
            }
        }

        public string LunarDay
        {
            get
            {
                int dayOfMonth = this._luar.GetDayOfMonth(this._datetime);
                string text = "初十廿三";
                string text2 = "一二三四五六七八九十";
                if ((dayOfMonth != 20) && (dayOfMonth != 30))
                {
                    return (text.Substring((dayOfMonth - 1) / 10, 1) + text2.Substring((dayOfMonth - 1) % 10, 1));
                }
                return (text.Substring(((dayOfMonth / 10) * 2) + 1, 2) + "十");
            }
        }

        public string LunarMonth
        {
            get
            {
                string text2;
                int month = this._luar.GetMonth(this._datetime);
                string text = "正二三四五六七八九十";
                if (month <= 10)
                {
                    text2 = "";
                    return (text2 + text.Substring(month - 1, 1) + "月");
                }
                if (month == 11)
                {
                    text2 = "十一";
                }
                else
                {
                    text2 = "腊";
                }
                return (text2 + "月");
            }
        }

        public string LunarYear
        {
            get
            {
                string text2 = "甲乙丙丁戊己庚辛壬癸";
                string text3 = "子丑寅卯辰巳午未申酉戌亥";
                string text4 = "鼠牛虎兔龙蛇马羊猴鸡狗猪";
                int year = this._luar.GetYear(this._datetime);
                return ((text2.Substring((year - 4) % 10, 1) + text3.Substring((year - 4) % 12, 1) + " ") + text4.Substring((year - 4) % 12, 1) + "年");
            }
        }

        public DateTime MaxSupportedDateTime
        {
            get
            {
                return this._luar.get_MaxSupportedDateTime();
            }
        }

        public DateTime MinSupportedDateTime
        {
            get
            {
                return this._luar.get_MinSupportedDateTime();
            }
        }
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -