C # to achieve lunar calendar calculation and conversion

xiaoxiao2021-04-04  238

/ * * Lunar calendar, by aiyao at www.5dz.net * /

Using system;

Namespace yyay.web.webclass {

#Region Use Example // You can cancel this code to get an example result. . // public class mytest // {// // method one, use Lunardate class // public string motor_d1 () // {// datetime _d = DateTime.now; // Lunardate LD = New Lunardate (_d); // String result = ""; // result = "Dedicated Year:" LD.LunaryEar "/ R / N"; // Result = "Zodiac:" LD.Animal "/ R / N"; / / Result = "Month:" LD.Lunarmonth "/ r / n"; // Result = "Japan:" ld.lunarday "/ r / n"; // result = "Shanning:" LD.SOLARTERM "/ r / n"; // Result = "Digital Lunar Year:" ld.year "Month" LD.MONTH "Day" LD.DAY "/ R / N" ; //} /// // method 2, use LunardateClass class // public string mothed2 () // {// datetime _d = datetime.now; // lunardateClass LDC = New LunardateClass (_d) ; // string result = ""; // result = "Dedicated Year:" LDC.Lunaryear "/ R / N"; // Result = "Zodiac:" LDC.Animal "/ R / N "; // result =" Month: " LDC.Lunarmonth " / r / n "; // Result =" Japan: " LDC.Lunarday " / R / N "; // Result =" Shanning: " ldc.solarterm " / r / n "; // //ldc.lunardate Returns the Lunardate object. . // RESULT = "Digital Lunar Year:" LDC.Lunardate.year "Month" LDC.Lunardate.Month "Day" LDC.Lunardate.day "/ R / N"; // Return RESULT //} //} # endregion # Region Lunardate

public class LunarDateClass {private const ushort START_YEAR = 1901; private const ushort END_YEAR = 2050; private DateTime m_Date = DateTime.MinValue; private LunarDate m_LunarDate = null; private string m_LunarYear = "", m_LunarMonth = "", m_LunarDay = ""; private String m_animal = "" ", m_constellation =", m_solarterm = ""; ///

Improve lunar calendar. public lunardateclass () {this.date = datetime.toDay;

///

initializes the lunar calendar in the question date. /// Initialize the date. To query the date. public lunardateclass (datetime dt) {this.date = dt.date;}

///

Initialize the date. To query the date. public datetime date {get {return m_date;} set {this.m_animal = "; this.m_contellation ="; this.m_lunardate = NULL; this.m_lunarday = "; this.m_lunarmonth =" THIS.M_Lunaryear = ""; this.m_solarterm = ""; m_date = value;}}

#Region LunardateClassData

///

Constellation name. Private String [] Constellationname = {"Aries", "Golden Bull", "Giant Cancer", "Leo", "Virgin", "Libra", "Scorpio", "Sagittari", " Capricorn "," Aquarius "," Pisces "};

///

The spiral name. private string [] lunarholdayname = {"Xiaoyan", "Big Han", "Li Spring", "Rain Water", "Spring", "Qingming", "Gu Yu", "Little Summer", "Small Man" "Mang", "Summer", "Xiaoxia", "Da Summer", "Bai Lu", "Bai Lu", "Autumn]" Hanu "," Frost "," Land "," Snow "," Snow "," winter "};

///

/// A number of glunarday deposits the number of monthly months in the middle of the month from 1901 to 2050, /// 阴 阴 历 costs per month can only be 29 or 30 days, 12 (or 13) binary The bit said, // / The corresponding position is 1 table 30 days, otherwise 29 days. /// The test data is only 1901.1.1 --2050.12.31 /// private int [] Glunarmonthday = {0x4ae0, 0xa570 , 0x5268, 0xd260, 0xd950, 0x6aa8, 0x56a0, 0x9ad0, 0x4ae8, 0x4ae0, // 1910 0xa4d8, 0xa4d0, 0xd250, 0xd548, 0xb550, 0x56a0, 0x96d0, 0x95b0, 0x49b8, 0x49b0, // 1920 0xa4b0, 0xb258, 0x6a50, 0x6d40 , 0xada8, 0x2b60, 0x9570, 0x4978, 0x4970, 0x64b0, // 1930 0xd4a0, 0xea50, 0x6d48, 0x5ad0, 0x2b60, 0x9370, 0x92e0, 0xc968, 0xc950, 0xd4a0, // 1940 0xda50, 0xb550, 0x56a0, 0xaad8, 0x25d0, 0x92d0 , 0xc958, 0xa950, 0xb4a8, 0x6ca0, // 1950 0xb550, 0x55a8, 0x4da0, 0xa5b0, 0x52b8, 0x52b0, 0xa950, 0xe950, 0x6aa0, 0xad50, // 1960 0xab50, 0x4b60, 0xa570, 0xa570, 0x5260, 0xe930, 0xd950, 0x5aa8 , 0x56a0, 0x96d0, // 1970 0x4ae8, 0x4ad0, 0xa4d0, 0xd268, 0xd250, 0xd528, 0xb540, 0xb6a0, 0x96d0, 0x95b0, // 1980 0x49b0, 0xa4b8, 0xa4b0, 0xb258, 0x6a50, 0x6d40, 0xada0, 0xab60, 0x9370, 0x4978 , // 1990 0x4970, 0x64b0, 0x6a50, 0xea50, 0x6b28, 0x5ac0, 0xab60, 0x9368, 0x92e0, 0xc960, // 2000 0xd4a8, 0xd4a0, 0xda50, 0x5aa8, 0x56a0, 0xaad8, 0x25d0, 0x92d0, 0xc958, 0xa950, // 2010 0xb4a0, 0xb550, 0xb550, 0x55a8, 0x4ba0, 0xa5b0, 0x52b8, 0x52b0, 0xa930, 0x74a8, // 2020 0x6aa0, 0xad50, 0x4da8, 0x4b60, 0x9570, 0xa4e0, 0xd260, 0xe930, 0xd530, 0x5aa0, // 2030 0x6b50, 0x96d0, 0x4ae8, 0x4ad0, 0xa4d0, 0xD258, 0xD250, 0xD520, 0xDAA0, 0XB5A0, / / ​​2040 0X56D0, 0X4AD8, 0X49B0, 0XA4B8, 0XA4B0, 0XAA50, 0XADA0, 0X6D20, 0XADA0, 0X55B0 / / 2050};

///

Array Glanarmont stores the month of the lunar calendar from 1901 to 2050, if it is 0, each word, two years private bote [] glunarmonth = {0x00, 0x50, 0x04, 0x00, 0x20, // 1910 0x60, 0x05, 0x00, 0x20, 0x70, // 1920 0x05, 0x00, 0x40, 0x02, 0x06, // 1930 0x00, 0x50, 0x03, 0x07, 0x00, // 1940 0x60, 0x04, 0x00, 0x20, 0x70, // 1950 0x05, 0x00, 0x30, 0x80, 0x06, // 1960 0x00, 0x40, 0x03, 0x07, 0x00, // 1970 0x50, 0x04, 0x08, 0x00, 0x60, // 1980 0x04, 0x0a, 0x00, 0x60, 0x05, // 1990 0x00, 0x30, 0x80, 0x05, 0x00, // 2000 0x40, 0x02, 0x07, 0x00, 0x50, // 2010 0x04, 0x09, 0x00, 0x60, 0x04, // 2020 0x00, 0x20, 0x60, 0x05, 0x00, // 2030 0x30, 0x50, // 2040 0x00, 0x50, // 2040 0x02, 0x07, 0x00, 0x50, 0x03 // 2050}; // array Glanarholiday stores each year's twenty-four kinds of gas Cumulative calendar date

/ / The number of twenty-four hollow calendars in the year is almost fixed, and the average distribution is distributed in 12 months / / January, September April May // Xiaoyan cold spring rain, the spring is clear, the Qingming Valley Yili Xia Xia Mang September 1, September 11, September, September, September, September, September, September, September, September, September, September, September, September, September September, September, September, September, September, September, September, September, September, September, September, September, September, September, Summer *********************************************************** ************ // The fierce has no determination law, so there is only a good memory, save space, so ... // ************* *********************************************************** ******************} // Data format Description: //, such as 1901 flying to //, January 8, April 8 July 8 September, September 11, December //6, 21, 4, 19, 6, 21, 5, 21, 6, 22, 6, 22, 8, 23, 8, 24, 8, 24, 8, 24 , 8, 23, 8, 22 // 9, 6, 11, 4, 9, 6, 10, 6, 9, 7, 9, 7, 7, 8, 7, 9, 7, 9, 7, 9, 7, 8, 7, 15 // The first line of data is the date of the monthly hollow, 15 minus the first holiday every month, and the second holiday will be reduced 15 to the second line // this month. The corresponding data is less than 16, stored in one byte, stores the first throttle data, the high position is stored // second hollow data, can be the following table private bote [] glunarholday =

{0x96, 0x97, 0x97, 0x78, 0x79, 0x79, 0x69, 0x78, 0x77, // 1901 0x96, 0xA4, 0x96, 0x96, 0x97, 0x87, 0x79, 0x79, 0x79, 0x69, 0x78, 0x78, // 1902 0x96, 0xa5, 0x87, 0x96, 0x87, 0x87, 0x79, 0x69, 0x69, 0x69, 0x78, 0x78, // 1903 0x86, 0xa5, 0x96, 0xa5, 0x96, 0x97, 0x88, 0x78, 0x78, 0x79, 0x78, 0x87, // 1904 0x96, 0x97, 0x97, 0x78, 0x79, 0x79, 0x69, 0x78, 0x77, // 1905 0x96, 0xa4, 0x96, 0x96, 0x97, 0x97, 0x79, 0x79, 0x79, 0x69, 0x78, 0x78, // 1906 0x96, 0xa5, 0x87, 0x96, 0x87, 0x87, 0x79, 0x69, 0x69, 0x69, 0x78, 0x78, // 1907 0x86, 0xa5, 0x96, 0xa5, 0x96, 0x97, 0x88, 0x78, 0x78, 0x69, 0x78, 0x87, // 1908 0x96, 0x97, 0x96, 0x78, 0x79, 0x79, 0x69, 0x78, 0x77, // 1909 0x96, 0xA4, 0x96, 0x96, 0x97, 0x97, 0x79, 0x79, 0x79, 0x69, 0x78, 0x78, // 1910 0x96, 0xa5, 0x87, 0x96, 0x87, 0x87, 0x79, 0x69, 0x69, 0x69, 0x78, 0x78, // 1911 0x86, 0xa5, 0x96, 0xa5, 0x96, 0x97, 0x88, 0x78, 0x78, 0x69, 0x78, 0x87, // 1912 0x95, 0xB4, 0x96, 0xA6, 0 X97, 0x97, 0x78, 0x79, 0x79, 0x69, 0x78, 0x77, // 1913 0x96, 0x97, 0x97, 0x79, 0x79, 0x79, 0x69, 0x78, 0x78, // 1914 0x96, 0xa5, 0x97, 0x96, 0x97, 0x87, 0x79, 0x79, 0x69, 0x69, 0x78, 0x78, // 1915 0x96, 0xa5, 0x96, 0xa5, 0x96, 0x97, 0x88, 0x78, 0x78, 0x79, 0x77, 0x87, // 1916 0x95, 0x96, 0x97, 0x78, 0x79, 0x78, 0x69, 0x78, 0x87, // 1917 0x96, 0x97, 0x97, 0x79, 0x79, 0x79, 0x69, 0x78, 0x77 , // 1918 0x96, 0xa5, 0x97, 0x96, 0x97, 0x87, 0x79, 0x79, 0x69, 0x69, 0x78, 0x78, // 1919 0x96, 0xa5, 0x96, 0xa5, 0x96, 0x97, 0x88, 0x78, 0x78, 0x79 , 0x77, 0x87, // 1920 0x95, 0xB4, 0x96, 0xA5, 0x96, 0x97, 0x78, 0x79, 0x78, 0x69, 0x78, 0x87, // 1921 0x96, 0x97, 0x96, 0xa6, 0x97, 0x97, 0x79,

0x79, 0x79, 0x69, 0x78, 0x77, // 1922 0x96, 0xA4, 0x96, 0x96, 0x97, 0x87, 0x79, 0x79, 0x69, 0x69, 0x78, 0x78, // 1923 0x96, 0xa5, 0x96, 0xa5, 0x96, 0x97, 0x88, 0x78, 0x78, 0x79, 0x77, 0x87, // 1924 0x95, 0x96, 0x96, 0xa5, 0x96, 0x97, 0x78, 0x79, 0x78, 0x69, 0x78, 0x87, // 1925 0x96, 0xB4, 0x96, 0xA6, 0x97, 0x97, 0x78, 0x79, 0x79, 0x69, 0x78, 0x77, // 1926 0x96, 0xa4, 0x96, 0x96, 0x97, 0x87, 0x79, 0x79, 0x79, 0x69, 0x78, 0x78, // 1927 0x96, 0xA5, 0x96, 0xa5, 0x96, 0x96, 0x88, 0x78, 0x78, 0x78, 0x87, 0x87, // 1928 0x95, 0x96, 0x97, 0x88, 0x78, 0x78, 0x79, 0x77, 0x87, / / 1929 0x96, 0xb4, 0x96, 0xa6, 0x97, 0x97, 0x78, 0x79, 0x79, 0x69, 0x78, 0x77, // 1930 0x96, 0xa4, 0x96, 0x96, 0x97, 0x87, 0x79, 0x79, 0x79, 0x69, 0x78 , 0x78, // 1931 0x96, 0xA5, 0x96, 0xa5, 0x96, 0x96, 0x88, 0x78, 0x78, 0x78, 0x87, 0x87, // 1932 0x95, 0x96, 0x97, 0x88, 0x78, 0x78 , 0x69, 0x78, 0x96, 0xb4, 0x96, 0xa6, 0x97, 0x97, 0x78, 0x79, 0x79, 0x69, 0x78, 0x77 , // 1934 0x96, 0xA4, 0x96, 0x96, 0x97, 0x97, 0x79, 0x79, 0x79, 0x69, 0x78, 0x78, // 1935 0x96, 0xa5, 0x96, 0xa5, 0x96, 0x96, 0x88, 0x78, 0x78, 0x78 , 0x87, 0x87, // 1936 0x95, 0x96, 0x97, 0x88, 0x78, 0x78, 0x69, 0x78, 0x87, // 1937 0X96, 0xB4, 0X96, 0XA6, 0x97, 0x97, 0x78, 0x79 , 0x79, 0x69, 0x78, 0x77, // 1938 0x96, 0xA4, 0x96, 0x96, 0x97, 0x97, 0x79, 0x79, 0x79, 0x69, 0x78, 0x78, // 1939 0x96, 0xa5, 0x96, 0xa5, 0x96, 0x96 , 0x88, 0x78, 0x78, 0x78, 0x87, 0x87, // 1940 0x95, 0x96, 0x97, 0x88, 0x78, 0x78, 0x69, 0x78, 0x87, // 1941 0x96, 0xB4, 0x96, 0xA6 , 0x97, 0x97, 0x78, 0x79, 0x79, 0x69, 0x78, 0x77, // 1942 0x96, 0xa4, 0x96, 0x96, 0x97, 0x97, 0x79, 0x79, 0x79, 0x69, 0x78, 0x78, // 1943 0x96,

0xA5, 0x96, 0xA5, 0xA6, 0x96, 0x88, 0x78, 0x78, 0x78, 0x87, 0x87, // 1944 0x95, 0x96, 0x97, 0x88, 0x78, 0x78, 0x79, 0x77, 0x87, / / 1945 0x95, 0xB4, 0x96, 0xA6, 0x97, 0x97, 0x78, 0x79, 0x78, 0x69, 0x78, 0x77, // 1946 0x96, 0x97, 0x97, 0x79, 0x79, 0x79, 0x69, 0x78 , 0x78, // 1947 0x96, 0xa5, 0xa6, 0xa5, 0xa6, 0x96, 0x88, 0x88, 0x78, 0x78, 0x87, 0x87, // 1948 0xa5, 0x96, 0x97, 0x88, 0x79, 0x78 , 0x79, 0x77, 0x87, // 1949 0x95, 0x96, 0x97, 0x78, 0x79, 0x78, 0x69, 0x78, 0x77, // 1950 0x96, 0xb4, 0x96, 0xa6, 0x97, 0x97, 0x79 , 0x79, 0x79, 0x69, 0x78, 0x78, // 1951 0x96, 0xa5, 0xa6, 0xa5, 0xa6, 0x96, 0x88, 0x88, 0x78, 0x78, 0x87, 0x87, // 1952 0xa5, 0xB4, 0x96, 0xa5, 0x96 , 0x97, 0x88, 0x78, 0x78, 0x79, 0x77, 0x87, // 1953 0x95, 0x96, 0x96, 0xa5, 0x96, 0x97, 0x78, 0x79, 0x78, 0x68, 0x78, 0x87, // 1954 0x96, 0xB4, 0x96 , 0xA6, 0x97, 0x97, 0x78, 0x79, 0x79, 0x69, 0x78, 0x77, // 1955 0x96, 0xa5, 0xa5, 0xa5, 0xa6, 0x96 , 0x88, 0x88, 0x78, 0x78, 0x87, 0x87, // 1956 0xa5, 0x96, 0x97, 0x88, 0x78, 0x78, 0x79, 0x77, 0x87, // 1957 0x95, 0xB4, 0x96, 0xa5 , 0x96, 0x97, 0x88, 0x78, 0x78, 0x69, 0x78, 0x87, // 1958 0x96, 0x7, 0x96, 0xa6, 0x97, 0x97, 0x78, 0x79, 0x79, 0x69, 0x78, 0x77, // 1959 0x96, 0xa4 , 0xa5, 0xa5, 0xa6, 0x96, 0x88, 0x88, 0x88, 0x78, 0x87, 0x87, // 1960 0xa5, 0xB4, 0x96, 0xA5, 0x96, 0x96, 0x88, 0x78, 0x78, 0x78, 0x87, 0x87, // 1961 0x96, 0x5, 0x96, 0x97, 0x88, 0x78, 0x78, 0x69, 0x78, 0x87, // 1962 0x96, 0x97, 0x97, 0x78, 0x79, 0x79, 0x69, 0x78, 0x77, // 1963 0x96, 0xa4, 0xa5, 0xa5, 0xa6, 0x96, 0x88, 0x88, 0x88, 0x78, 0x87, 0x87, // 1964 0xa5, 0x96, 0x96, 0x88, 0x78, 0x78,

0x78, 0x87, 0x87, // 1965 0x95, 0x96, 0x97, 0x88, 0x78, 0x78, 0x69, 0x78, 0x87, // 1966 0x96, 0x97, 0x96, 0xa6, 0x97, 0x97, 0x78, 0x79, 0x79, 0x69, 0x78, 0x77, // 1967 0x96, 0xa4, 0xa5, 0x88, 0xa6, 0xa6, 0x88, 0x88, 0x88, 0x78, 0x87, 0x87, // 1968 0XA5, 0X96, 0x96, 0x88, 0x78, 0x78, 0x78, 0x87, 0x87, // 1969 0x95, 0x96, 0x96, 0xa5, 0x96, 0x97, 0x88, 0x78, 0x78, 0x69, 0x78, 0x87, // 1970 0x96, 0xB4, 0x96, 0xA6, 0x97, 0x97, 0x78, 0x79, 0x79, 0x69, 0x78, 0x77, // 1971 0X96, 0XA4, 0XA5, 0XA5, 0XA6, 0XA6, 0X88, 0X88, 0X88, 0X78, 0X87, 0X87, / / ​​1972 0XA5, 0xB5, 0x96, 0xA5, 0xA6, 0x96, 0x88, 0x78, 0x78, 0x78, 0x87, 0x87, // 1973 0x95, 0x96, 0x96, 0xa5, 0x96, 0x97, 0x88, 0x78, 0x78, 0x69, 0x78, 0x87, / / 1974 0x96, 0xB4, 0x96, 0xA6, 0x97, 0x97, 0x78, 0x79, 0x78, 0x69, 0x78, 0x77, // 1975 0x96, 0xa4, 0xa5, 0x88, 0xa6, 0xa6, 0x88, 0x89, 0x88, 0x78, 0x87 , 0x87, // 1976 0xa5, 0xB4, 0x96, 0xA5, 0x96, 0x96, 0x88, 0x88, 0x78, 0x78, 0x87, 0x87, // 1977 0 X95, 0xB4, 0x96, 0xA5, 0x96, 0x97, 0x88, 0x78, 0x78, 0x79, 0x78, 0x87, // 1978 0x96, 0x96, 0x97, 0x78, 0x79, 0x78, 0x69, 0x78, 0x77 , // 1979 0x96, 0xA4, 0xA5, 0x888, 0x88, 0x88, 0x78, 0x87, 0x87, // 1980 0xa5, 0xa6, 0x96, 0x88, 0x888, 0x78, 0x78 , 0x77, 0x87, // 1981 0x95, 0x96, 0x97, 0x88, 0x78, 0x78, 0x79, 0x77, 0x87, // 1982 0x95, 0xB4, 0x96, 0xa5, 0x96, 0x97, 0x78, 0x79 , 0x78, 0x69, 0x78, 0x77, // 1983 0x96, 0xa6, 0xa6, 0x87, 0x88, 0x88, 0x78, 0x87, 0x87, // 1984 0xa5, 0xa6, 0x96 , 0x88, 0x88, 0x78, 0x78, 0x87, 0x87, // 1985 0xa5, 0x96, 0x97, 0x88, 0x78, 0x78, 0x79, 0x77, 0x87, // 1986 0x95, 0xB4, 0x96,

0xA5, 0x96, 0x97, 0x88, 0x79, 0x78, 0x69, 0x78, 0x87, // 1987 0x96, 0xa6, 0xa6, 0x87, 0x88, 0x88, 0x78, 0x87, 0x86, // 1988 0xa5, 0xB4, 0xA5, 0xA5, 0xA6, 0x96, 0x88, 0x88, 0x88, 0x78, 0x87, 0x87, // 1989 0xa5, 0x96, 0x96, 0x88, 0x78, 0x78, 0x79, 0x77, 0x87, / / 1990 0x95, 0xb4, 0x96, 0xa5, 0x86, 0x97, 0x88, 0x78, 0x78, 0x69, 0x78, 0x87, // 1991 0x96, 0xA6, 0xa5, 0x87, 0x888, 0x88, 0x78, 0x87 , 0x86, // 1992 0xa5, 0xa6, 0x96, 0x88, 0x88, 0x88, 0x78, 0x87, 0x87, // 1993 0xa5, 0x96, 0x96, 0x888, 0x78, 0x78 , 0x78, 0x87, 0x87, // 1994 0x95, 0x96, 0x97, 0x88, 0x76, 0x78, 0x69, 0x78, 0x87, // 1995 0x96, 0xa6, 0xa5, 0x, 0xa6, 0xa6, 0x87 , 0x88, 0x88, 0x78, 0x87, 0x86, // 1996 0XA5, 0XA6, 0XA5, 0XA5, 0XA6, 0XA6, 0X88, 0X88, 0X88, 0X78, 0X87, 0x87, // 1997 0xa5, 0xb4, 0x96, 0xa5, 0x96 , 0x96, 0x88, 0x78, 0x78, 0x78, 0x87, 0x87, // 1998 0x95, 0xB4, 0x96, 0xa5, 0x96, 0x97, 0x88, 0x78 , 0x78, 0x69, 0x78, 0x87, // 1999 0x96, 0xa6, 0xa6, 0x87, 0x88, 0x88, 0x78, 0x87, 0x86, // 2000 0xa5, 0x, 0xa5, 0xa5, 0xa6, 0xa6 , 0x88, 0x88, 0x88, 0x78, 0x87, 0x87, // 2001 0xa5, 0x96, 0x96, 0x88, 0x78, 0x78, 0x78, 0x87, 0x87, // 2002 0x95, 0xb4, 0x96, 0xa5 , 0x96, 0x97, 0x88, 0x78, 0x78, 0x69, 0x78, 0x87, // 2003 0x96, 0xa6, 0xa5, 0x87, 0x88, 0x88, 0x78, 0x87, 0x86, // 2004 0XA5, 0XB3 , 0xa5, 0xa5, 0xa6, 0xa6, 0x88, 0x88, 0x88, 0x78, 0x87, 0x87, // 2005 0xa5, 0xa6, 0x96, 0xa5, 0xa6, 0x96, 0x88, 0x88, 0x78, 0x78, 0x87, 0x87, // 2006 0x95, 0x96, 0x97, 0x88, 0x78, 0x78, 0x69, 0x78, 0x87, // 2007 0x96, 0xa6, 0xa6, 0x87, 0x88, 0x87, 0x78, 0x87,

0x86, // 2008 0xa5, 0xa6, 0xa6, 0x88, 0x88, 0x88, 0x78, 0x87, 0x87, // 2009 0xa5, 0xa6, 0x96, 0xa5, 0xa6, 0x96, 0x88, 0x88, 0x78, 0x78, 0x87, 0x87, // 2010 0x95, 0xb4, 0x96, 0xa5, 0x96, 0x97, 0x88, 0x78, 0x78, 0x79, 0x78, 0x87, // 2011 0x96, 0xb4, 0xa5, 0x, 0x, 0xa5, 0xa6, 0x87, 0x88, 0x87, 0x78, 0x87, 0x86, // 2012 0xa5, 0xb3, 0xa5, 0x87, 0x88, 0x88, 0x78, 0x87, 0x87, // 2013 0xa5, 0x, 0x96, 0xa5, 0xa6, 0x96, 0x88, 0x88, 0x78, 0x78, 0x87, 0x87, // 2014 0x95, 0x96, 0x97, 0x88, 0x78, 0x78, 0x79, 0x77, 0x87, // 2015 0x95, 0xB4, 0xA5, 0xB4, 0xA5, 0xA6, 0x87, 0x88, 0x87, 0x78, 0x87, 0x86, // 2016 0xa5, 0xA6, 0xA6, 0x87, 0x88, 0x88, 0x78, 0x87, 0x87, // 2017 0xa5, 0xB4, 0xA6, 0xA5, 0xA6, 0x96, 0x88, 0x88, 0x78, 0x78, 0x87, 0x87, // 2018 0xa5, 0x96, 0x96, 0x88, 0x96, 0x96, 0x88, 0x78, 0x78, 0x79, 0x77, 0x87, / / 2019 0x95, 0xB4, 0XA5, 0XB4, 0XA5, 0XA6, 0X97, 0X87, 0x87, 0x78, 0x87, 0x86, // 2020 0xa5, 0xc3, 0 XA5, 0XB5, 0XA6, 0XA6, 0X87, 0X88, 0X88, 0X78, 0X87, 0X86, // 2021 0XA5, 0XA6, 0X9, 0XA5, 0XA6, 0X96, 0X88, 0X88, 0X88, 0X78, 0X87, 0x87, // 2022 0xa5, 0x96, 0x96, 0x88, 0x78, 0x78, 0x79, 0x77, 0x87, // 2023 0x95, 0xa5, 0xa5, 0x97, 0x87, 0x87, 0x78, 0x87, 0x96 , // 2024 0xA5, 0xc3, 0xa5, 0x87, 0x88, 0x88, 0x78, 0x87, 0x86, // 2025 0XA5, 0XA6, 0XA5, 0XA5, 0XA6, 0XA6, 0X88, 0X88, 0X88, 0X78 , 0x87, 0x87, // 2026 0xa5, 0x96, 0x96, 0x88, 0x78, 0x78, 0x78, 0x87, 0x87, // 2027 0x95, 0xa5, 0xa5, 0x97, 0x87 , 0x87, 0x78, 0x87, 0x96, // 2028 0xa5, 0xc3, 0xa5, 0x, 0x87, 0x88, 0x88, 0x78, 0x87, 0x86, // 2029 0xa5, 0x, 0xa5, 0xa5, 0xA6,

0xA6, 0x88, 0x88, 0x88, 0x78, 030 0xa5, 0x96, 030 0xa5, 0x96, 0x96, 0x88, 0x78, 0x78, 0x78, 0x87, 0x87, // 2031 0x95, 0xB4, 0xA5, 0xB4, 0xA5, 0xA6, 0x97, 0x87, 0x87, 0x78, 0x87, 0x96, // 2032 0XA5, 0XA6, 0XA5, 0X888, 0XA6, 0XA6, 0X88, 0X88, 0X88, 0x78, 0x87, 0x86, // 2033 0XA5, 0xB3, 0xA5, 0xA5, 0xA6, 0xA6, 0x88, 0x78, 0x88, 0x78, 0x87, 0x87, // 2034 0xa5, 0xa6, 0x96, 0xa5, 0xa6, 0x96, 0x88, 0x88, 0x78, 0x78, 0x87, 0x87, / / 2035 0x95, 0xB4, 0xA5, 0X97, 0XA5, 0XA6, 0X97, 0X87, 0x87, 0x78, 0x87, 0x96, // 2036 0XA5, 0XC3, 0XA5, 0X87, 0X888, 0x88, 0x78, 0x87 , 0x86, // 2037 0xa5, 0xa6, 0xa6, 0x88, 0x88, 0x88, 0x78, 0x87, 0x87, // 2038 0xa5, 0x, 0xA6, 0x96, 0x88, 0x88, 0x78 , 0x78, 0x87, 0x87, // 2039 0x95, 0xa5, 0xa6, 0x97, 0x87, 0x87, 0x78, 0x87, 0x96, // 2040 0XA5, 0XC3, 0XA5, 0XB5, 0XA5, 0XA6, 0X87 , 0x88, 0x87, 0x78, 0x87, 0x86, // 2041 0XA5, 0XB3, 0XA5, 0xB5, 0XA6, 0XA6, 0X88, 0X88, 0X88, 0X78 , 0x87, 0x87, // 2042 0xa5, 0xa6, 0x96, 0x88, 0x88, 0x78, 0x78, 0x87, 0x87, // 2043 0x95, 0xa5, 0xa6, 0x97, 0x87 , 0x87, 0x88, 044 0xa5, 0xc3, 0xa5, 0x, 0x87, 0x88, 0x87, 0x78, 0x87, 0x86, // 2045 0XA5, 0XA6, 0XA6, 0xA6 , 0x87, 0x88, 0x88, 0x78, 046 0xa5, 0xa6, 0x96, 0xa5, 0xa6, 0x96, 0x88, 0x88, 0x78, 0x78, 0x87, 0x87, // 2047 0x95, 0xB4, 0XA5, 0XB4 , 0xa5, 0xa5, 0x97, 0x87, 0x87, 0x88, 048 0xa4, 0xc3, 0xa5, 0xa5, 0xa5, 0xa6, 0x97, 0x87, 0x87, 0x78, 0x87, 0x86, // 2049 0XA5, 0XC3 , 0xA5, 0xB5, 0xA6, 0xA6, 0x87, 0x88, 0x78, 0x78, 0x87, 0x87 // 2050}; # endregion

#Region Core

///

/// acquires the 阴 月 月 份 份 份 份 份 份 份 份 份/// /// Year. /// Returns the monthly month of the designated year. private int GetLeapMonth (ushort iLunarYear) {byte Flag; if (iLunarYear END_YEAR) {return 0;} Flag = gLunarMonth [(iLunarYear - START_YEAR) / 2]; if ((iLunarYear - START_YEAR )% 2 == 0) {RETURN FLAG >> 4;} else {returnif & 0x0f;}}

///

/// calculates the total number of days in the designated yin calendar year. /// /// Year. /// Month. /// /// Returns the number of days of the lunar calendar month, if the month is the month, high character is the second month, otherwise the high words are 0. /// /// /// The specified annual range is between January 1901 to December 2050. /// private uint GetLunarMonthDays (ushort iLunarYear, ushort iLunarMonth) {int Height, Low; int iBit; if (iLunarYear END_YEAR) {return 30;} Height = 0; Low = 29; Ibit = 16 - ilunarmonth; IF (ilunarmonth> getleapmonth && getleapmonth (ilunaryear)> 0) {ibit--;}

IF ((Glunarmonthday [ilunaryear - start_year] & (1 << ibit))> 0)

{Low ;}

IF (ilunarmonth == getleapmonth (ilunaryear) {IF ((glunarmonthday [ilunaryear - start_year] & (1 << (ibit - 1)))> 0) {height = 30;} else {height = 29;}} return (UINT) (T) (UINT) << 16; // combined into uint}

///

/// calculates the total number of days of the designated yin calendar year. /// /// Specifies the lunar calendar, range 1901-2050. /// Returns the total number of days in the yin calendar year. private INT getLunaryEardAys (ushort iLunaryear) {int days; uint tmp; if (ilunaryear End_year) {return 0;} days = 0; for (Ushort I = 1; i <= 12; i ) {TMP = getlunarmontHDAYS (iLunaryear, i); days = days ((TMP >> 16) & 0xfff); // Take high DAYS = DAYS (Ushort) (TMP); // Take low} Return days;

///

/// Calculates from January 1, 1901 through IsPandays day //////////// /// returned. /// The month returned. /// The day returned. /// days. Private Void Calclunardate (Out Ushort Iyear, Out Ushort IMONTH, OUT USHORT IDAY, UINT ISPANDAYS) {uint tmp; // Cumulament February 19, 1901 for the lunar calendar 1901, first month, first month, first month, January 1901 1st to February 19th there is a total of 49 days if (ISPANDAYS <49) {ibra = start_year - 1; if (ISPANDAYS <19) {IMONTH = 11; iDay = (Ushort);} else {imth = 12; iDay = (ushort) (ISPANDAYS - 18);} return;}

// The following from the lunar calendar 1901, ISPANDAYS = ISPANDAYS - 49; IYear = start_year; IMONTH = 1; iDay = 1; // Computing Year TMP = (uint) getLunaryEardAys (Iyear); while (ispandays> = TMP ) {ISPANDAYS = ISPANDAYS - TMP; IYEAR ; TMP = (uint) getLunaryEardAys (Iyear);} // calculation month TMP = getLunarmontHDAYS (Iyear, IMONTH); // Take low WHILE (ispandays> = TMP) {ISPANDAYS = ISPANDAYS - TMP; IF (IMONTH == Getleapmonth (Iyear)) {TMP = (Iyear, IMONTH) >> 16) & 0xfff; // Take high IF (ISPANDAYS

#Region constellation

///

/// calculates the constellation serial number of the specified current date. /// /// Constellation serial number. private int getConstellationIndex () {int y, m, d; y = m_date.year; m_date.month; d = m_date.day; y = m * 100 d; if (y> = 321 && Y <= 419) {RETURN 0;} else if (y> = 420 && y <= 520) {RETURN 1;} else if (y> = 521 && y <= 620) {RETURN 2;} else if (Y > = 621 && y <= 722) {RETURN 3;} else if (y> = 723 && y <= 822) {RETURN 4;} else if (y> = 823 && y <= 922) {Return 5;} ELSE IF (Y> = 923 && y <= 1022) {RETURN 6;} else if (y> = 1023 && y <= 1121) {RETURN 7;} else if (y> = 1122 && y <= 1221) { Return 8;} else if (y> = 1222 || y <= 119) {RETURN 9;} else if (y> = 120 && y <= 218) {return 10;} else if (y> = 219 && y <= 320) {RETURN 11;} else {return -1;}} /// /// formatting star serial number is a constellation name. /// /// Constellation serial number. /// Constellation name. Private string formatConstellation (int cabletellationIndex) {if (constellationINDEX> = 0 && constellationINDEX <= 11) {return constellationname [constellationIndex];} else {return ";}}

#ndregion

#Region

///

/// calculate the throttle number corresponding to the questionnaire. /// /// Return Value 0-23 is the hollow sequence number, and -1 is not a throttle. Private int getSolartermindex () {byte flag; int day, iodies; iv; = m_date.year; if (iyear > 4) & 0x0f);} else {day = (Flag & 0x0f) 15;

IF (iDay == day) {if (iDay> 15) {RETURN (IMONTH - 1) * 2 1;} else {return (IMONTH - 1) * 2;}} else {return -1;}}

///

/// formatting the throttle number is the solar terms. /// /// The hollow serial number. /// Soil Name. Private string formatsolarterm (int solartermindex) {// String [] stroe = {"Xiaoyan", "Big Han", "Li Shu", "Rain Water", "Spring", "Qingming", "Gu Yu" "," Lixia "," Small Full "," Mang "," Summer "," Summer "," Summer "," Bai Lu "," Autumn "," Hanu "," Frost ", "Large Winter", "Snow", "Snow", "Winter Swarf"}; if (Solartermindex <= this.lunarholdenseName.Length && Solartermindex> = 0) Return this.lunarholdenseName [solartermindex]; Return ""

#ndregion

#Region Annual Month Day

///

/// format the lunar month. /// /// Year. /// Dry A New Year. Private string formatlunaryear (int iodary "{string strg =" methyl hydrofuthenogeng 庚 辛 "; string strz =" Ziqiu Yuchen is not Shen Hui Hai "; return strg.substring ((Iyear - 4)% 10 1) strz.substring (Iyear - 4)% 12, 1);} /// /// format the lunar year. /// /// Year. /// Zodiac. Private string formatanimalyear (int iod) {string strsx = "Mouse Niuhui Free Dragon Snake Pigher Wool Monkey Chicken Chicken Pig"; Return STRSX.SUBSTRING ((IYear - 4)% 12, 1);}

///

/// format the lunar month. /// /// Month. /// Chinese month. Private string formatlunarmonth (int tenth) {string sztext = "正 二三 三三 四" "; IF (IMONTH <= 10) Return Sztext.Substring (IMONTH - 1, 1) " Month " ; If (IMONTH == 11) Return "November"; if (IMONTH == 12) Return "December"; Return ";

///

/// Format the lunar calendar day. /// /// days. /// Chinese days. Private string formatlunarday (int iD iDay) {string sztext1 = "first ten third"; string sztext2 = "One two three four five six seven eight ninety"; string strDay = ""; if (iDay! = 20 && iday! = 30) {Try {straday = sztext1.substring ((iDay - 1) / 10, 1); strDay = strDay sztext2.substring ((iDay - 1)% 10, 1);} catch (Exception) {}} Else {strday = sztext1.substring ((iDay / 10), 1); strDay = strday "ten";}} #endregion;} #ENDREGION

#REGION OUTPUT

///

The valence date is expressed in the form of Lunardate. public Lunardate Lunardate {Get {IF (this.m_lunardate == Null) {ushort Iyear, IMONTH, IDAY; ​​TIMESPAN TS = m_date - (Start_Year, 1, 1)); this.calclunardate (Out Iyear) , OUT IMONTH, OUT iDAY, (TS.DAYS)); this.m_lunardate = New Lunardate (Iyear, IMONTH, IDAY);} return this.m_lunardate;}}

///

Yunlun Dry Rise. public string lunaryear {geet {if (m_lunaryear == ") this.m_lunaryear = this.formatlunaryear (this.lunardate.year); returnid t t;}}

///

阴 历 生. public string animal {get {if (m_animal == ") this.m_animal = this.formataiMalyear (this.lunardate.year); returnim_animal;}}

///

After formatting the lunar month. public string LunarMonth {get {if (this.m_LunarMonth == "") this.m_LunarMonth = this.FormatLunarMonth (ushort.Parse (this.LunarDate.Month.ToString ())); return this.m_LunarMonth;} } /// Formatted Lunu Day. public string lunarday {get {ix (this.m_lunarday == ") this.m_lunarday = this.formatlunarday (this.lunardate.day.tostring ())))))); Return this.m_lunarday;} }

///

Formatted the lunar calendar. public string solarterm {geet {if (this.m_solarterm == ") this.m_solarterm = this.formatsolarterm (this.getsolartermindex ()); return this.m_solarterm;}}

///

Formatted constellation. public string constellation {geet {if (this.m_constellation == ") this.m_constellation = this.formatConstellation (this.getConstellationIndex ()); returnim_constellation;}}

#ndregion}

Public class lunardte {private int _y, _m, _d; private string lunardate = ""; private string lunarmonth = ", lunarday =", lunaryear = ""; private string solarterm = ", animal ="

public LunarDate (DateTime dt) {LunarDateClass ldc = new LunarDateClass (dt); this.lunarday = ldc.LunarDay; this.lunarmonth = ldc.LunarMonth; this.lunaryear = ldc.LunarYear; this.solarterm = ldc.SolarTerm; this. Animal = ldc.animal; this.lunardate = this.lunaryear "(" this.animal ") year" this.lunarmonth this.lunarday (this.solarterm == "" "": "" This.Solarterm; this._y = ldc.lunardate.year; this._m = ldc.lunardate.mont; this._d = ldc.lunardate.day;} public lunardate (int y, int m, int d) {this ._y = y; this._m = m; this._d = D;} public int year {get {return this._y;}}

Public int MONTH {Get {Return this._m;}}

Public int day {get {return this._d;}}

Public string lunarday {get {return this.lunarday;}}

Public String Lunarmonth {get {returnid t tararmonth;}}

Public string lunaryear {get {return this.lunaryear;}}

Public string solarterm {get {return this.solarterm;}}

Public string animal {get {returnid.animal;}}

Public new string toString () {return this.lunardate;}}

#ndregion

}

转载请注明原文地址:https://www.9cbs.com/read-131759.html

New Post(0)