VB.NET's rogue calendar and lunar conversion algorithm

xiaoxiao2021-03-06  63

'Below is a lunar calendar algorithm for VB

'Date data definition method is as follows

'The first 12 bytes represent from January-December for the day, 1 for the day of the month, 0 is 29 days in Xiaoyue;

The 13th place is the case of the month, 1 is 30 days in the month, 0 is 29 days in the month;

'No. 14 is the month of the month, if it is not a month of 0, otherwise give the month, 10, 11, 12 respectively use A, B, C, respectively, even if the 16 is used;

'The last 4 is the Lunar New Year of the New Year - the date of the Gregorian calendar on January 1, such as 0131 on behalf of January 31.

Function getchgdate (Byval vdate as string, byval chgtype as conversion method) AS String

DIM VVDATE () AS STRING = Split (vdate, "-")

IF vvdate (0)> 2011 or vvdate (0) <1900 Then

Throw New NotSupportedException ("This function only provides 2900 to 2011 calendar conversion!")

END IF

Dim Addmonth, AddDay, Addyear, Getday, I as integer

DIM Runyue as Boolean

DIM CONDATE AS DATETIME

DIM Dalist (2011) AS String

Dalist (1900) = "010010110110180131"

Dalist (1901) = "010010101110000219"

Dalist (1902) = "101001010111000208"

Dalist (1903) = "010100100110150129"

Dalist (1904) = "110100100110000216"

Dalist (1905) = "110110010101000204"

Dalist (1906) = "011010101010140125"

Dalist (1907) = "010101101010000213"

Dalist (1908) = "100110101101000202"

Dalist (1909) = "010010101110120122"

Dalist (1910) = "010010101110000210"

Dalist (1911) = "101001001101160130"

Dalist (1912) = "101001001101000218"

Dalist (1913) = "110100100101000206"

Dalist (1914) = "110101010100150126"

Dalist (1915) = "101101010101000214"

Dalist (1916) = "010101101010000204"

Dalist (1917) = "100101101101020123"

Dalist (1918) = "100101011011000211"

Dalist (1919) = "010010011011170201"

Dalist (1920) = "010010011011000220"

Dalist (1921) = "101001001011000208" DALIST (1922) = "101100100101150128"

Dalist (1923) = "011010100101000216"

Dalist (1924) = "011011010100000205"

Dalist (1925) = "101011011010140124"

Dalist (1926) = "00101010110110000213"

Dalist (1927) = "100101010111000202"

Dalist (1928) = "010010010111120123"

Dalist (1929) = "010010010111000210"

Dalist (1930) = "011001001011060130"

Dalist (1931) = "110101001010000217"

Dalist (1932) = "111010100101000206"

Dalist (1933) = "011011010100150126"

Dalist (1934) = "010110101101000214"

Dalist (1935) = "001010110110000204"

Dalist (1936) = "100100110111030124"

Dalist (1937) = "100100101110000211"

Dalist (1938) = "110010010110170131"

Dalist (1939) = "110010010101000219"

Dalist (1940) = "110101001010000208"

Dalist (1941) = "110110100101060127"

Dalist (1942) = "101101010101000215"

Dalist (1943) = "010101101010000205"

Dalist (1944) = "101010101101140125"

Dalist (1945) = "001001011101000213"

Dalist (1946) = "100100101101000202"

Dalist (1947) = "110010010101120122"

Dalist (1948) = "101010010101000210"

Dalist (1949) = "101101001010170129"

Dalist (1950) = "011011001010000217"

Dalist (1951) = "101101010101000206"

Dalist (1952) = "010101011010150127"

Dalist (1953) = "010011011010000214"

Dalist (1954) = "101001011011000203"

Dalist (1955) = "010100101011130124"

Dalist (1956) = "010100101011000212" DALIST (1957) = "101010010101080131"

Dalist (1958) = "111010010101000218"

Dalist (1959) = "01101010101010000208"

Dalist (1960) = "101011010101060128"

Dalist (1961) = "101010110101000215"

Dalist (1962) = "010010110110000205"

Dalist (1963) = "101001010111040125"

Dalist (1964) = "101001010111000213"

Dalist (1965) = "010100100110000202"

Dalist (1966) = "111010010011030121"

Dalist (1967) = "110110010101000209"

Dalist (1968) = "010110101010170130"

Dalist (1969) = "010101101010000217"

Dalist (1970) = "100101101101000206"

Dalist (1971) = "010010101110150127"

Dalist (1972) = "010010101101000215"

Dalist (1973) = "101001001101000203"

Dalist (1974) = "110100100110140123"

Dalist (1975) = "110100100101000211"

Dalist (1976) = "110101010010180131"

Dalist (1977) = "101101010100000218"

Dalist (1978) = "101101101010000207"

Dalist (1979) = "100101101101060128"

Dalist (1980) = "100101011011000216"

Dalist (1981) = "010010011011000205"

Dalist (1982) = "101001001011140125"

Dalist (1983) = "101001001011000213"

Dalist (1984) = "1011001001011A0202"

Dalist (1985) = "011010100101000220"

Dalist (1986) = "011011010100000209"

Dalist (1987) = "101011011010060129"

Dalist (1988) = "101010110110000217"

Dalist (1989) = "100100110111000206"

Dalist (1990) = "010010010111150127"

Dalist (1991) = "010010010111000215" DALIST (1992) = "011001001011000204"

Dalist (1993) = "011010100101030123"

DALIST (1994) = "111010100101000210"

Dalist (1995) = "011010110010180131"

Dalist (1996) = "010110101100000219"

Dalist (1997) = "101010110110000207"

Dalist (1998) = "100100110110150128"

Dalist (1999) = "100100101110000216"

Dalist (2000) = "110010010110000205"

DALIST (2001) = "110101001010140124"

Dalist (2002) = "110101001010000212"

Dalist (2003) = "110110100101000201"

Dalist (2004) = "010110101010120122"

Dalist (2005) = "010101101010000209"

Dalist (2006) = "101010101101170129"

Dalist (2007) = "001001011101000218"

Dalist (2008) = "100100101101000207"

Dalist (2009) = "110010010101150126"

Dalist (2010) = "101010010101000214"

Dalist (2011) = "101101001010000214"

Addyear = vvdate (0)

If chgtype = conversion method. 阴 阴 转 阳历 t

AddMonth = VAL (MID (Dalist (AddYear), 15, 2))

Addday = VAL (MID (Dalist (AddYear), 17, 2))

Condate = dateserial (addyear, addmonth, addday)

Addday = vvdate (2)

For i = 1 to vvdate (1) - 1

Addday = addday 29 val (MID (Dalist (Vvdate (0)), I, 1)

Next I

Return Dateadd (DateInterVal.day, AddDay - 1, Condate)

Else

Chushihua:

AddMonth = VAL (MID (Dalist (AddYear), 15, 2))

Addday = VAL (MID (Dalist (AddYear), 17, 2))

Condate = dateserial (addyear, addmonth, addday)

DIM VTDATE AS DATETIME

Try

vtdate = ctype (vdate, datetime)

Catch exception

Throw New NotSupportedException ("Cumulator Note Enter By!")

END TRY

Getday = datediff (DateInterVal.day, Condate, VTDate)

IF getday <0 Then adyear = addyar - 1: goto chushihua

Addday = 1

Addmonth = 1

For i = 1 to getday

Addday = addday 1

IF addday = 30 mid (Dalist (addyear), Addmonth, 1) or (Runyue and AddDay = 30 MID (Dalist (AddYear), 13, 1))

IF Runyue = false and addmonth = VAL ("& H" & MID (Dalist (AddYear), 14, 1))

Runyue = TRUE

Else

Runyue = false

Addmonth = Addmonth 1

END IF

Addday = 1

END IF

NEXT

Return Addyear & "-" & AddMonth & "-" & addday

END IF

END FUNCTION

ENUM conversion method

Lunar calendar transfer class = 1

Comeling calendar = 0

END ENUM

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

New Post(0)