public string get_ChineseZodiac(System.DateTime date)
 {
     System.Globalization.EastAsianLunisolarCalendar cc = new System.Globalization.ChineseLunisolarCalendar();
     int sexagenaryYear = cc.GetSexagenaryYear(date);
     int terrestrialBranch = cc.GetTerrestrialBranch(sexagenaryYear);
     //string[] years = "rat,ox,tiger,hare,dragon,snake,horse,sheep,monkey,fowl,dog,pig".Split(',');
     string[] years = "Rat,Ox,Tiger,Rabbit,Dragon,Snake,Horse,Goat,Monkey,Rooster,Dog,Pig".Split(',');
     return years[terrestrialBranch - 1];
 }
Example #2
0
        public string CalcChineseSign()
        {
            System.Globalization.EastAsianLunisolarCalendar cc = new System.Globalization.ChineseLunisolarCalendar();
            int sexagenaryYear    = cc.GetSexagenaryYear(Birth);
            int terrestrialBranch = cc.GetTerrestrialBranch(sexagenaryYear);

            string[] years = new string[] { "Rat", "Ox", "Tiger", "Rabbit", "Dragon", "Snake", "Horse", "Goat", "Monkey", "Rooster", "Dog", "Pig" };

            return(years[terrestrialBranch - 1]);
        }
        public string get_ChineseZodiac(System.DateTime date)
        {
            System.Globalization.EastAsianLunisolarCalendar cc = new System.Globalization.ChineseLunisolarCalendar();
            int sexagenaryYear    = cc.GetSexagenaryYear(date);
            int terrestrialBranch = cc.GetTerrestrialBranch(sexagenaryYear);

            //string[] years = "rat,ox,tiger,hare,dragon,snake,horse,sheep,monkey,fowl,dog,pig".Split(',');
            string[] years = "Rat,Ox,Tiger,Rabbit,Dragon,Snake,Horse,Goat,Monkey,Rooster,Dog,Pig".Split(',');
            return(years[terrestrialBranch - 1]);
        } // End Function get_ChineseZodiac
Example #4
0
        /// <summary>
        /// 获取指定时间的生肖属性
        /// </summary>
        /// <param name="timr">指定的时间</param>
        /// <returns></returns>
        public static string Animal_Date(DateTime timr)
        {
            System.Globalization.ChineseLunisolarCalendar chinseCaleander = //创建日历对象
                                                                            new System.Globalization.ChineseLunisolarCalendar();
            string TreeYear = "鼠牛虎兔龙蛇马羊猴鸡狗猪";                               //创建字符串对象
            int    intYear  = chinseCaleander.GetSexagenaryYear(timr);      //计算年信息

            return(TreeYear.Substring(chinseCaleander.                      //得到生肖信息
                                      GetTerrestrialBranch(intYear) - 1, 1));
        }
Example #5
0
        /// <summary>
        /// 获得生肖
        /// </summary>
        /// <param name="birthday"></param>
        /// <returns></returns>
        public static string GetShengXiao(DateTime birthday)
        {
            System.Globalization.ChineseLunisolarCalendar chinseCaleander = new System.Globalization.ChineseLunisolarCalendar();

            string TreeYear = "鼠牛虎兔龙蛇马羊猴鸡狗猪";

            int intYear = chinseCaleander.GetSexagenaryYear(birthday);

            string Tree = TreeYear.Substring(chinseCaleander.GetTerrestrialBranch(intYear) - 1, 1);

            return(Tree);
        }
        static void ChineseTest()
        {
            var dt = DateTime.Now;

            Console.WriteLine(dt);
            //中国农历
            var zhcal     = new System.Globalization.ChineseLunisolarCalendar();
            int yearIndex = zhcal.GetSexagenaryYear(dt);
            int yTG       = zhcal.GetCelestialStem(yearIndex);
            int yDZ       = zhcal.GetTerrestrialBranch(yearIndex);

            Console.WriteLine($"{_celestialStem[yTG - 1]}{_terrestrialBranch[yDZ - 1]}  {_chineseZodiac[yDZ - 1]}年  {_chineseMonth[zhcal.GetMonth(dt) - 1]}月{_chineseDay[zhcal.GetDayOfMonth(dt) - 1]}");
        }
Example #7
0
        internal string ChineseSignCalc()
        {
            var c = new System.Globalization.ChineseLunisolarCalendar();
            var y = c.GetSexagenaryYear(BirthDate.Value);
            var s = c.GetCelestialStem(y) - 1;

            return
                (",Rat,Ox,Tiger,Rabbit,Dragon,Snake,Horse,Goat,Monkey,Rooster,Dog,Pig".Split(',')[
                     c.GetTerrestrialBranch(y)]
                 + " - "
                 + "Wood,Fire,Earth,Metal,Water".Split(',')[s / 2]
                 + " - Y" + (s % 2 > 0 ? "in" : "ang"));
        }
        private void btn_Get_Click(object sender, EventArgs e)
        {
            System.Globalization.ChineseLunisolarCalendar chinseCaleander =    //建立日曆物件
                                                                            new System.Globalization.ChineseLunisolarCalendar();
            string TreeYear = "鼠牛虎兔龍蛇馬羊猴雞狗豬";                                  //建立字串物件
            int    intYear  = chinseCaleander.GetSexagenaryYear(DateTime.Now); //計算年訊息
            string Tree     = TreeYear.Substring(chinseCaleander.              //得到生肖訊息
                                                 GetTerrestrialBranch(intYear) - 1, 1);

            MessageBox.Show("今年是十二生肖" + Tree + "年",//輸出生肖訊息
                            "判斷十二生肖", MessageBoxButtons.OK,
                            MessageBoxIcon.Information);
        }
Example #9
0
        private void btn_Get_Click(object sender, EventArgs e)
        {
            System.Globalization.ChineseLunisolarCalendar chinseCaleander =    //创建日历对象
                                                                            new System.Globalization.ChineseLunisolarCalendar();
            string TreeYear = "鼠牛虎兔龙蛇马羊猴鸡狗猪";                                  //创建字符串对象
            int    intYear  = chinseCaleander.GetSexagenaryYear(DateTime.Now); //计算年信息
            string Tree     = TreeYear.Substring(chinseCaleander.              //得到生肖信息
                                                 GetTerrestrialBranch(intYear) - 1, 1);

            MessageBox.Show("今年是十二生肖" + Tree + "年",//输出生肖信息
                            "判断十二生肖", MessageBoxButtons.OK,
                            MessageBoxIcon.Information);
        }
Example #10
0
        // https://www.yourchineseastrology.com/zodiac/how-to-calculate-animal-sign.htm
        public static string GetChineseZodiac(System.DateTime date)
        {
            System.Globalization.EastAsianLunisolarCalendar cc =
                new System.Globalization.ChineseLunisolarCalendar();
            int sexagenaryYear    = cc.GetSexagenaryYear(date);
            int terrestrialBranch = cc.GetTerrestrialBranch(sexagenaryYear);

            // string[] years = "rat,ox,tiger,hare,dragon,snake,horse,sheep,monkey,fowl,dog,pig".Split(',');
            // string[] years = "Rat,Ox,Tiger,Rabbit,Dragon,Snake,Horse,Goat,Monkey,Rooster,Dog,Pig".Split(',');
            // string[] years = new string[]{ "rat", "ox", "tiger", "hare", "dragon", "snake", "horse", "sheep", "monkey", "fowl", "dog", "pig" };
            string[] years = new string[] { "Rat", "Ox", "Tiger", "Rabbit", "Dragon", "Snake", "Horse", "Goat", "Monkey", "Rooster", "Dog", "Pig" };

            return(years[terrestrialBranch - 1]);
        } // End Function get_ChineseZodiac
Example #11
0
        static void Main(string[] args)
        {
            var dt = DateTime.Parse("2019/06/02");

            Console.WriteLine(dt);
            Console.WriteLine("----------------------------------");

            //日本日历
            var jpci  = new System.Globalization.CultureInfo("ja-JP");
            var jpcal = new System.Globalization.JapaneseCalendar();

            jpci.DateTimeFormat.Calendar = jpcal;
            Console.WriteLine(dt.ToString("ggyy/MM/dd", jpci));

            Console.WriteLine("----------------------------------");
            //中国农历
            var zhcal     = new System.Globalization.ChineseLunisolarCalendar();
            int yearIndex = zhcal.GetSexagenaryYear(dt);
            int yTG       = zhcal.GetCelestialStem(yearIndex);
            int yDZ       = zhcal.GetTerrestrialBranch(yearIndex);

            Console.WriteLine($"{_celestialStem[yTG-1]}{_terrestrialBranch[yDZ-1]}  {_chineseZodiac[yDZ - 1]}年  {_chineseMonth[zhcal.GetMonth(dt)-1]}月{_chineseDay[zhcal.GetDayOfMonth(dt)-1]}");
        }